Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
18 changes: 15 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
FROM node:14
FROM node:16

WORKDIR .

COPY package*.json .
RUN npm i --production
ARG NODE_ENV
ARG DATABASE_URL
ARG GOOGLE_CLIENT_ID
ARG GOOGLE_CLIENT_SECRET
ARG AUTH_SECRET
ARG AUTH_URL
ARG NEXT_PUBLIC_BASE_URL
ARG NEXT_PUBLIC_MAPTILER_ACCESS_TOKEN
ARG SENDGRID_API_KEY
ARG SENDGRID_SENDER

COPY package*.json .
RUN npm ci --production
RUN npm i --save-dev typescript postcss ts-node sharp
COPY . .
RUN npm run db:generate
RUN npm run build
EXPOSE 3000

Expand Down
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,23 @@ npx prisma studio
```

## Start production server
Create a file named `.env.production`:
```
NODE_ENV=production

DATABASE_URL=postgresql://computational_puzzles:computational_puzzles@db:5432/mydb?schema=public&connect_timeout=300
GOOGLE_CLIENT_ID=10889722286-8uek1esq4uicv31an6tehi60c7ev5lvp.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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
SECRET=secret
AUTH_SECRET=secret
AUTH_URL=http://localhost:3000

NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_MAPTILER_ACCESS_TOKEN=uTyRuREEmko5kblSVwhb
```
Then, run the following command
```bash
docker-compose build
docker-compose up
docker-compose up -- build
```

## For testing
Expand Down
30 changes: 23 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,39 @@ version: "3.6"

services:
app:
build: .
env_file: .env
build:
context: .
dockerfile: Dockerfile
args:
NODE_ENV: ${NODE_ENV}
DATABASE_URL: ${DATABASE_URL}
GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID}
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
AUTH_SECRET: ${AUTH_SECRET}
AUTH_URL: ${AUTH_URL}
NEXT_PUBLIC_BASE_URL: ${NEXT_PUBLIC_BASE_URL}
NEXT_PUBLIC_MAPTILER_ACCESS_TOKEN: ${NEXT_PUBLIC_MAPTILER_ACCESS_TOKEN}
SENDGRID_API_KEY: ${SENDGRID_API_KEY}
SENDGRID_SENDER: ${SENDGRID_SENDER}
env_file: .env.production
image: computational_puzzles
volumes:
- ./:/app
ports:
- "3000:3000"
volumes:
- app:/app
depends_on:
- db
networks:
- app_network

links:
- db:db

db:
image: postgres:9.6
container_name: computational_puzzle_db
volumes:
- db_data:/var/lib/postgresql/data
env_file: .env
env_file: .env.production
environment:
POSTGRES_USER: computational_puzzles
POSTGRES_PASSWORD: computational_puzzles # This is used to create development database, please change when migrate to production
Expand All @@ -28,7 +45,6 @@ services:
- app_network

volumes:
app:
db_data:

networks:
Expand Down
Loading