-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14b3928
commit e700ecb
Showing
3 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Stage 1: Install dependencies and build the app | ||
FROM node:20 AS builder | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Copy package.json and yarn.lock | ||
COPY package.json yarn.lock ./ | ||
|
||
# Install dependencies | ||
RUN yarn install --frozen-lockfile --ignore-scripts | ||
|
||
# Copy the rest of the application code | ||
COPY . . | ||
|
||
# Build the Next.js app | ||
RUN yarn build | ||
|
||
# Stage 2: Run the app with a smaller image | ||
FROM builder AS runner | ||
|
||
# Set working directory | ||
WORKDIR /app | ||
|
||
# Install only production dependencies | ||
COPY --from=builder /app/node_modules ./node_modules | ||
COPY --from=builder /app/package.json ./ | ||
|
||
# Copy the built application from the builder stage | ||
COPY --from=builder /app/.next ./.next | ||
COPY --from=builder /app/public ./public | ||
|
||
# Expose the port on which the app runs | ||
EXPOSE 3000 | ||
|
||
# Set environment variables (optional) | ||
ENV NODE_ENV=production | ||
|
||
# Run the app | ||
CMD ["yarn", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: portfolio | ||
|
||
services: | ||
app: | ||
container_name: portfolio-app | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
ports: | ||
- '4002:3000' | ||
environment: | ||
- NEXT_PUBLIC_ENV=local | ||
- NEXT_PUBLIC_BASE_URL="http://localhost:4002" | ||
- NEXT_PUBLIC_GA_MEASUREMENT_ID=GA_MEASUREMENT_ID | ||
- NEXT_PUBLIC_EXPERIMENTAL=true | ||
- DATABASE_URL=postgres://postgres:Qwerty123@database:5432/portfolio | ||
- REDIS_URL=redis://cache:6379/1 | ||
- SENTRY_DSN=https://d16140d5bf02f802b5d2134985cf176c@o4506720354304000.ingest.us.sentry.io/4507581075619840 | ||
depends_on: | ||
- database | ||
- cache | ||
networks: | ||
- portfolio-network | ||
|
||
database: | ||
container_name: portfolio-db | ||
image: postgres:latest | ||
restart: unless-stopped | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: Qwerty123 | ||
POSTGRES_DB: portfolio | ||
networks: | ||
- portfolio-network | ||
volumes: | ||
- portfolio-postgres:/var/lib/postgresql/data | ||
|
||
cache: | ||
container_name: portfolio-redis | ||
image: redis:latest | ||
restart: unless-stopped | ||
networks: | ||
- portfolio-network | ||
|
||
networks: | ||
portfolio-network: | ||
driver: bridge | ||
|
||
volumes: | ||
portfolio-postgres: | ||
driver: local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters