Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions ganesh/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
FROM --platform=linux/amd64 node:20
# Use the official Node.js image
FROM --platform=linux/amd64 node:20-alpine AS builder

# Set working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./
RUN npm install

# Install dependencies
RUN npm install --frozen-lockfile

# Copy the entire project
COPY . .

# Generate Prisma client
RUN npx prisma generate

# Build Next.js app
RUN npm run build

# Create a lightweight production image
FROM --platform=linux/amd64 node:20-alpine AS runner

WORKDIR /app

# Copy only necessary files from the builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json

# Set environment variables for production
ENV NODE_ENV=production
ENV PORT=3000

# Expose port 3000
EXPOSE 3000

CMD [ "npm", "run", "dev" ]
# Start the Next.js app in production mode
CMD ["npm", "run", "start"]
6 changes: 6 additions & 0 deletions ganesh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Rode todos os passos a seguir no diretório `/ganesh`.
9. Na rota '/admin', você poderá logar com email: `[email protected]` e senha: `password`.
10. Caso queira terminar, `docker compose down`.

##### Para produção

1. Rode `docker compose build`.
2. Rode `docker compose up -d`.


##### Caso queira deletar o usuário

Rode `npm run delete`.
Expand Down
18 changes: 9 additions & 9 deletions ganesh/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
version: "3.8"

services:
app:
build: .
restart: on-failure
restart: always
ports:
- 3000:3000
- "3000:3000"
environment:
DATABASE_URL: ${DATABASE_URL_PRODUCTION}
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
volumes:
- .:/app # Mount the local directory into the container
- node_modules:/app/node_modules # Ensure node_modules inside the container is not overwritten
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
NODE_ENV: production
depends_on:
- postgres
networks:
- app-network

postgres:
image: postgres:13-alpine
restart: on-failure
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- 5432:5432
- "5432:5432"
volumes:
- postgres_database:/var/lib/postgresql/data/
networks:
- app-network

volumes:
postgres_database:
node_modules:

networks:
app-network:
Loading