Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/build docker #105

Merged
merged 28 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
94ac7b7
feat: add docker start into backend
iaurg Nov 18, 2023
7a1b344
fix: import not declared into build
iaurg Nov 18, 2023
99262b3
feat: update docker based on nextjs example
iaurg Nov 18, 2023
d3a07eb
refactor: docker compose
iaurg Nov 18, 2023
772322f
feat: add new configs into docker
iaurg Nov 18, 2023
3096d71
feat: add configure to make up for validation
iaurg Nov 20, 2023
1882178
Feat/users status (#97)
iaurg Nov 20, 2023
a5e3fc7
fix: hardcoded localhost game socket (#106)
iaurg Nov 20, 2023
3b3e7d1
Feature: Add chat actions (#104)
vcwild Nov 21, 2023
4a63830
fix: chat width (#113)
iaurg Nov 22, 2023
bfd95fc
Fix: Remove some bugs from chat context (#110)
vcwild Nov 22, 2023
decb7bd
Merge branch 'main' into feat/build-docker
iaurg Nov 23, 2023
9e6076e
fix: downgrade nextjs
iaurg Nov 23, 2023
cbf0bb0
feat: update packages and configs
iaurg Nov 23, 2023
88c7822
feat: update examples
iaurg Nov 23, 2023
e5016aa
feat: add restart into backend image
iaurg Nov 23, 2023
cb3d51e
docs: add seed and reset example
iaurg Nov 23, 2023
d63b3b8
fix: update command based on pdf
iaurg Nov 23, 2023
8381bf5
chore: update locj
iaurg Nov 23, 2023
17e4282
chore: update nextjs
iaurg Nov 23, 2023
2a64aba
refactor: backend fast startup
iaurg Nov 24, 2023
9c44723
Merge branch 'main' into feat/build-docker
iaurg Nov 24, 2023
6bcabd2
Merge branch 'main' into feat/build-docker
Dec 2, 2023
e8ffc62
Updates docker deployment details
Dec 2, 2023
277bc7a
Updates deployment details
Dec 4, 2023
292f5e6
Simplifies backend entrypoint
Dec 4, 2023
0ab7b6c
chore: updates lockfile
Dec 4, 2023
aa0faf9
Enables docker entrypoint again
Dec 5, 2023
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
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POSTGRES_USER="user"
POSTGRES_PASSWORD="password"
POSTGRES_DB="postgres"
POSTGRES_HOST="database"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: up

up:
docker-compose -f docker-compose.yml up -d
docker-compose -f docker-compose.yml up --build -d

up-refresh:
docker-compose -f docker-compose.yml up -d --build -V --force-recreate
Expand Down
1 change: 1 addition & 0 deletions backend/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Dockerfile
.dockerignore
node_modules
node_modules/*
npm-debug.log
dist
11 changes: 2 additions & 9 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
DOMAIN="" # domain to use for cookies (default: localhost)
APP_NAME="Confia Driven Development"
FRONTEND_URL="http://localhost:9000"
############################### Prisma Setup ################################
POSTGRES_USER="user"
POSTGRES_PASSWORD="password"
POSTGRES_DB="postgres"
POSTGRES_HOST="postgres"

DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?schema=public"
FRONTEND_URL="http://localhost:9090"

############################### Intra Auth Setup ###############################
INTRA_CLIENT_ID=""
Expand All @@ -19,5 +12,5 @@ JWT_SECRET=""
ACCESS_TOKEN_EXPIRATION="" # 15m # Increase to stay logged in for longer without refreshing
REFRESH_TOKEN_EXPIRATION="" # 7d # after this time, the user will have to log in again

################################## HASH Secret ##################################
################################## HASH Secret #################################
HASH_PEPPER="" # At least 16 bytes long for security (128 bits) (32 bytes recommended)
42 changes: 37 additions & 5 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
FROM node:18
FROM node:20-alpine as base
WORKDIR /usr/src/app

WORKDIR /usr/src/app/server
##############
# DEPENDENCIES
##############
FROM base AS dependencies
# https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine
RUN apk add --no-cache libc6-compat

COPY --chown=node:node package*.json ./

RUN npm ci

#############
# DEVELOPMENT
#############
FROM base as development

COPY --from=dependencies /usr/src/app/node_modules ./node_modules
COPY . .

RUN npm install
RUN npm run prisma:generate

CMD ["npm", "run", "start:dev"]

# ##########
# PRODUCTION
# ##########
FROM base as production
ENV NODE_ENV=production

COPY --from=dependencies --chown=node:node /usr/src/app/node_modules ./node_modules
COPY --chown=node:node . .

RUN npm run prisma:generate
RUN npm run build
RUN npm ci --omit=dev && npm cache clean --force

EXPOSE 3000
USER node

CMD [ "npm", "run", "start" ]
EXPOSE 3000

ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["npm", "run", "start:prod"]
8 changes: 8 additions & 0 deletions backend/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e

export DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:5432/${POSTGRES_DB}?schema=public"

npm run prisma:migrate:deploy

exec "$@"
Loading
Loading