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

Improve docker compose setup #117

Merged
merged 1 commit into from
Dec 13, 2024
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
Binary file modified backend/.yarn/install-state.gz
Binary file not shown.
15 changes: 15 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20

WORKDIR /app

COPY . .

RUN rm -rf node_modules
RUN yarn install
RUN yarn build

EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:3000/health || exit 1

CMD ["bash", "start-server.sh"]
5 changes: 3 additions & 2 deletions backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ version: '3.8'

services:
app:
image: node:20
build:
context: .
dockerfile: Dockerfile
container_name: node_app
working_dir: /usr/src/app
volumes:
- .:/usr/src/app
ports:
- '3000:3000'
entrypoint: ['bash', 'start-server.sh']
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "tsc",
"start:server": "node --loader ts-node/esm src/server.ts",
"start": "node --loader ts-node/esm",
"start": "node dist/server.js",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --coverage",
"lint": "eslint . "
},
Expand Down Expand Up @@ -44,7 +44,7 @@
"@types/jsonwebtoken": "^9",
"@types/lru-cache": "^7.10.10",
"@types/multer": "^1.4.12",
"@types/node": "^22.3.0",
"@types/node": "^22.10.2",
"@types/pg": "^8.11.10",
"@types/pg-format": "^1",
"@types/uuid": "^10",
Expand Down
2 changes: 0 additions & 2 deletions backend/start-server.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
yarn install
yarn build
yarn db-migrate up
node dist/server.js
17 changes: 13 additions & 4 deletions backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,7 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:*, @types/node@npm:>=13.7.0, @types/node@npm:^22.3.0":
"@types/node@npm:*, @types/node@npm:>=13.7.0":
version: 22.10.0
resolution: "@types/node@npm:22.10.0"
dependencies:
Expand All @@ -2182,6 +2182,15 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^22.10.2":
version: 22.10.2
resolution: "@types/node@npm:22.10.2"
dependencies:
undici-types: "npm:~6.20.0"
checksum: 10c0/2c7b71a040f1ef5320938eca8ebc946e6905caa9bbf3d5665d9b3774a8d15ea9fab1582b849a6d28c7fc80756a62c5666bc66b69f42f4d5dafd1ccb193cdb4ac
languageName: node
linkType: hard

"@types/pg-format@npm:^1":
version: 1.0.5
resolution: "@types/pg-format@npm:1.0.5"
Expand Down Expand Up @@ -3445,7 +3454,7 @@ __metadata:
"@types/jsonwebtoken": "npm:^9"
"@types/lru-cache": "npm:^7.10.10"
"@types/multer": "npm:^1.4.12"
"@types/node": "npm:^22.3.0"
"@types/node": "npm:^22.10.2"
"@types/pg": "npm:^8.11.10"
"@types/pg-format": "npm:^1"
"@types/uuid": "npm:^10"
Expand Down Expand Up @@ -8346,11 +8355,11 @@ __metadata:

"typescript@patch:typescript@npm%3A^5.6.3#optional!builtin<compat/typescript>":
version: 5.7.2
resolution: "typescript@patch:typescript@npm%3A5.7.2#optional!builtin<compat/typescript>::version=5.7.2&hash=cef18b"
resolution: "typescript@patch:typescript@npm%3A5.7.2#optional!builtin<compat/typescript>::version=5.7.2&hash=5786d5"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/c891ccf04008bc1305ba34053db951f8a4584b4a1bf2f68fd972c4a354df3dc5e62c8bfed4f6ac2d12e5b3b1c49af312c83a651048f818cd5b4949d17baacd79
checksum: 10c0/f3b8082c9d1d1629a215245c9087df56cb784f9fb6f27b5d55577a20e68afe2a889c040aacff6d27e35be165ecf9dca66e694c42eb9a50b3b2c451b36b5675cb
languageName: node
linkType: hard

Expand Down
7 changes: 3 additions & 4 deletions docker-compose.base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ networks:

services:
backend:
image: node:20
container_name: node_app
build:
context: ./backend
dockerfile: Dockerfile
working_dir: /usr/src/app
volumes:
- ./backend:/usr/src/app
ports:
- "3000:3000"
restart: unless-stopped
environment:
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
hasura:
image: hasura/graphql-engine:v2.40.0
depends_on:
app:
backend:
condition: service_healthy
volumes:
- ./hasura/metadata:/hasura-metadata
Expand Down Expand Up @@ -49,9 +49,10 @@ services:
command:
- graphql-engine
- serve
app:
image: node:20
container_name: node_app
backend:
build:
context: ./backend
dockerfile: Dockerfile
working_dir: /usr/src/app
volumes:
- ./backend:/usr/src/app
Expand All @@ -63,4 +64,3 @@ services:
interval: 30s
timeout: 10s
retries: 5
entrypoint: ["bash", "start-server.sh"]
Loading