Skip to content

Commit

Permalink
fix: docker config local and dev/prod (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
achauve authored Jul 19, 2024
1 parent 6a9c463 commit b912d88
Show file tree
Hide file tree
Showing 18 changed files with 1,731 additions and 3,406 deletions.
9 changes: 6 additions & 3 deletions .kontinuous/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ jobs:
use: build
with:
imagePackage: backend
context: packages/backend
context: ./
dockerfile: packages/backend/Dockerfile

build-frontend-usagers:
use: build
Expand All @@ -131,7 +132,8 @@ jobs:
name: matomo
with:
imagePackage: frontend-usagers
context: packages/frontend-usagers
context: ./
dockerfile: packages/frontend-usagers/Dockerfile
buildArgs:
NUXT_PUBLIC_BACKEND_URL: "https://api-{{ .Values.global.host }}"
NUXT_PUBLIC_MATOMO_ENABLED: "${FRONTEND_USAGERS_MATOMO_ENABLED}"
Expand All @@ -148,7 +150,8 @@ jobs:
name: matomo
with:
imagePackage: frontend-bo
context: packages/frontend-bo
context: ./
dockerfile: packages/frontend-bo/Dockerfile
buildArgs:
NUXT_PUBLIC_BACKEND_URL: "https://api-{{ .Values.global.host }}"
NUXT_PUBLIC_MATOMO_ENABLED: "${FRONTEND_BO_MATOMO_ENABLED}"
Expand Down
26 changes: 10 additions & 16 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ volumes:

services:
frontend-usagers:
build:
context: .
dockerfile: packages/frontend-usagers/Dockerfile.local
image: "node:20.15.1-bullseye-slim"
working_dir: /app
command: /app/packages/frontend-usagers/entrypoint.sh
command: bash -c "/app/packages/frontend-usagers/start.sh"
volumes:
- $PWD:/app:delegated
- $HOME/.ssh:/home/node/.ssh:ro
- $HOME/.gitconfig:/home/node/.gitconfig:ro
- $HOME/.npm:/home/node/.npm:delegated
- $HOME/.cache/yarn:/home/node/.cache/yarn:delegated
env_file:
- ./.env
environment:
Expand All @@ -28,16 +26,14 @@ services:
- 3000:3000

frontend-bo:
build:
context: .
dockerfile: packages/frontend-bo/Dockerfile.local
image: "node:20.15.1-bullseye-slim"
working_dir: /app
command: /app/packages/frontend-bo/entrypoint.sh
command: bash -c "/app/packages/frontend-bo/start.sh"
volumes:
- $PWD:/app:delegated
- $HOME/.ssh:/home/node/.ssh:ro
- $HOME/.gitconfig:/home/node/.gitconfig:ro
- $HOME/.npm:/home/node/.npm:delegated
- $HOME/.cache/yarn:/home/node/.cache/yarn:delegated
env_file:
- ./.env
environment:
Expand All @@ -53,16 +49,14 @@ services:
- 3001:3000

backend:
build:
context: packages/backend
dockerfile: Dockerfile.local
image: "node:20.15.1-bullseye-slim"
working_dir: /app
command: /app/entrypoint.sh
command: bash -c "/app/packages/backend/start.sh"
volumes:
- $PWD/packages/backend:/app:delegated
- $PWD:/app:delegated
- $HOME/.ssh:/home/node/.ssh:ro
- $HOME/.gitconfig:/home/node/.gitconfig:ro
- $HOME/.npm:/home/node/.npm:delegated
- $HOME/.cache/yarn:/home/node/.cache/yarn:delegated
depends_on:
postgres:
condition: service_started
Expand Down
20 changes: 10 additions & 10 deletions packages/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@ FROM node:$NODE_VERSION AS build

WORKDIR /app

COPY ./package.json ./yarn.lock ./
RUN yarn --frozen-lockfile

COPY . .

RUN yarn install --production && yarn cache clean
COPY package.json yarn.lock ./
COPY packages/backend/package.json packages/backend/yarn.lock packages/backend/
RUN yarn workspace @vao/backend install --frozen-lockfile --production

#--- Run stage

FROM node:$NODE_VERSION

USER 1000
WORKDIR /app

ENV NODE_ENV: production

COPY --from=build /app/package.json /app/package.json
COPY --from=build /app/node_modules /app/node_modules
COPY --from=build /app/src /app/src
COPY --from=build /app/package.json /app/yarn.lock ./
COPY --from=build /app/node_modules node_modules
COPY --from=build /app/packages/backend/package.json /app/packages/backend/yarn.lock packages/backend/
COPY --from=build /app/packages/backend/node_modules packages/backend/node_modules
COPY packages/backend/src packages/backend/src

# Note: Don't use "yarn start" as it doesn't handle linux signals (graceful shutdown for instance)
CMD ["node", "src/index.js"]
CMD ["node", "packages/backend/src/index.js"]


16 changes: 0 additions & 16 deletions packages/backend/Dockerfile.local

This file was deleted.

7 changes: 0 additions & 7 deletions packages/backend/entrypoint.sh

This file was deleted.

13 changes: 7 additions & 6 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@
"dev": "nodemon --inspect=0.0.0.0:9229 src/index.js"
},
"dependencies": {
"@sentry/node": "~7.118.0",
"@sentry/node": "~7.118.0",
"axios": "^1.6.8",
"body-parser": "~1.20.2",
"cookie-parser": "^1.4.6",
"cors": "~2.8.5",
"cron": "~3.1.7",
"dayjs": "^1.11.10",
"db-migrate": "~0.11.14",
"db-migrate-pg": "~1.5.2",
"debug": "~4.3.4",
"express": "~4.19.2",
"helmet": "~7.1.0",
"helmet": "~7.1.0",
"jsonwebtoken": "^9.0.2",
"multer": "^1.4.5-lts.1",
"pg": "~8.12.0",
"pg-format": "~1.0.4",
"yup": "~1.4.0",
"nodemailer": "^6.9.13",
"pdfmake": "^0.2.10",
"cron": "~3.1.7"
"pg": "~8.12.0",
"pg-format": "~1.0.4",
"ufo": "^1.5.4",
"yup": "~1.4.0"
},
"devDependencies": {
"@socialgouv/eslint-config-recommended": "^1.131.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

yarn workspace @vao/backend install
exec yarn workspace @vao/backend dev
86 changes: 43 additions & 43 deletions packages/backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -660,55 +660,55 @@
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==

"@sentry-internal/tracing@7.117.0":
version "7.117.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.117.0.tgz#c7d2357dae8d7ea2bc130e4513ac4ffc8dc7553c"
integrity sha512-fAIyijNvKBZNA12IcKo+dOYDRTNrzNsdzbm3DP37vJRKVQu19ucqP4Y6InvKokffDP2HZPzFPDoGXYuXkDhUZg==
dependencies:
"@sentry/core" "7.117.0"
"@sentry/types" "7.117.0"
"@sentry/utils" "7.117.0"

"@sentry/core@7.117.0":
version "7.117.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.117.0.tgz#eebdb6e700d5fbdf3102c4abfb4ff92ef79ae9a5"
integrity sha512-1XZ4/d/DEwnfM2zBMloXDwX+W7s76lGKQMgd8bwgPJZjjEztMJ7X0uopKAGwlQcjn242q+hsCBR6C+fSuI5kvg==
dependencies:
"@sentry/types" "7.117.0"
"@sentry/utils" "7.117.0"

"@sentry/integrations@7.117.0":
version "7.117.0"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.117.0.tgz#4613dae3bc1d257c3c870461327fd4f70dbda229"
integrity sha512-U3suSZysmU9EiQqg0ga5CxveAyNbi9IVdsapMDq5EQGNcVDvheXtULs+BOc11WYP3Kw2yWB38VDqLepfc/Fg2g==
dependencies:
"@sentry/core" "7.117.0"
"@sentry/types" "7.117.0"
"@sentry/utils" "7.117.0"
"@sentry-internal/tracing@7.118.0":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.118.0.tgz#1a96ea745db818e20c2f8273d317f284a416a90a"
integrity sha512-dERAshKlQLrBscHSarhHyUeGsu652bDTUN1FK0m4e3X48M3I5/s+0N880Qjpe5MprNLcINlaIgdQ9jkisvxjfw==
dependencies:
"@sentry/core" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry/core@7.118.0":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.118.0.tgz#1549b49621bc05a8df16c3546793a299b0638559"
integrity sha512-ol0xBdp3/K11IMAYSQE0FMxBOOH9hMsb/rjxXWe0hfM5c72CqYWL3ol7voPci0GELJ5CZG+9ImEU1V9r6gK64g==
dependencies:
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry/integrations@7.118.0":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.118.0.tgz#f090db621979785c6dc44406da1f72653fa0617c"
integrity sha512-C2rR4NvIMjokF8jP5qzSf1o2zxDx7IeYnr8u15Kb2+HdZtX559owALR0hfgwnfeElqMhGlJBaKUWZ48lXJMzCQ==
dependencies:
"@sentry/core" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"
localforage "^1.8.1"

"@sentry/node@~7.117.0":
version "7.117.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.117.0.tgz#a548e7c2d395e01818814573b5f420eb061ebcf9"
integrity sha512-0MWXdT8dv1MtQGF0aeB8LQTBTJS1L1Vz24+wvdXroR3/52mPYrPWlzuc7+Ew/Dlqdlb5LKVIlkuDSRWj8UKpTQ==
"@sentry/node@~7.118.0":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.118.0.tgz#c0b78cabc737eb8a638e82f338fc533455552117"
integrity sha512-79N63DvYKkNPqzmc0cjO+vMZ/nU7+CbE3K3COQNiV7gk58+666G9mRZQJuZVOVebatq5wM5UR0G4LPkwD+J84g==
dependencies:
"@sentry-internal/tracing" "7.117.0"
"@sentry/core" "7.117.0"
"@sentry/integrations" "7.117.0"
"@sentry/types" "7.117.0"
"@sentry/utils" "7.117.0"
"@sentry-internal/tracing" "7.118.0"
"@sentry/core" "7.118.0"
"@sentry/integrations" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry/types@7.117.0":
version "7.117.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.117.0.tgz#c4d89aba487c05f4e5cbfa2f1c65180b536393b4"
integrity sha512-5dtdulcUttc3F0Te7ekZmpSp/ebt/CA71ELx0uyqVGjWsSAINwskFD77sdcjqvZWek//WjiYX1+GRKlpJ1QqsA==
"@sentry/types@7.118.0":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.118.0.tgz#ca3ab06912f60bc2a7ccf2d2e5ccf43985851aef"
integrity sha512-2drqrD2+6kgeg+W/ycmiti3G4lJrV3hGjY9PpJ3bJeXrh6T2+LxKPzlgSEnKFaeQWkXdZ4eaUbtTXVebMjb5JA==

"@sentry/utils@7.117.0":
version "7.117.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.117.0.tgz#ac367a6f623bd09440b39d947437009c0ffe52b2"
integrity sha512-KkcLY8643SGBiDyPvMQOubBkwVX5IPknMHInc7jYC8pDVncGp7C65Wi506bCNPpKCWspUd/0VDNWOOen51/qKA==
"@sentry/utils@7.118.0":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.118.0.tgz#bfc60826fe3d5d2ae7338ec6ac1f06c20beb179e"
integrity sha512-43qItc/ydxZV1Zb3Kn2M54RwL9XXFa3IAYBO8S82Qvq5YUYmU2AmJ1jgg7DabXlVSWgMA1HntwqnOV3JLaEnTQ==
dependencies:
"@sentry/types" "7.117.0"
"@sentry/types" "7.118.0"

"@sinclair/typebox@^0.27.8":
version "0.27.8"
Expand Down
19 changes: 0 additions & 19 deletions packages/frontend-bo/Dockerfile.local

This file was deleted.

6 changes: 0 additions & 6 deletions packages/frontend-bo/entrypoint.sh

This file was deleted.

4 changes: 4 additions & 0 deletions packages/frontend-bo/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

yarn workspace @vao/frontend-bo install
exec yarn workspace @vao/frontend-bo dev
2 changes: 1 addition & 1 deletion packages/frontend-usagers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ RUN yarn workspace @vao/frontend-usagers generate

FROM ghcr.io/socialgouv/docker/nginx4spa:8.2.3

COPY --from=builder --chown=101:101 /app/.output/public /usr/share/nginx/html
COPY --from=builder --chown=101:101 /app/packages/frontend-usagers/.output/public /usr/share/nginx/html
19 changes: 0 additions & 19 deletions packages/frontend-usagers/Dockerfile.local

This file was deleted.

7 changes: 0 additions & 7 deletions packages/frontend-usagers/entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion packages/frontend-usagers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "Apache-2.0",
"scripts": {
"build": "nuxt build",
"dev": "rm -rf /tmp/nitro && nuxt dev",
"dev": "rm -rf /tmp/nitro && yarn workspace @vao/frontend-usagers nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend-usagers/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

yarn workspace @vao/frontend-usagers install
exec yarn workspace @vao/frontend-usagers dev
2 changes: 1 addition & 1 deletion packages/migrations/Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM local-node:latest as builder
USER root

WORKDIR /usr/cache
COPY package*.json yarn.lock ./
COPY package.json yarn.lock ./

RUN chown -R node /usr/cache

Expand Down
Loading

0 comments on commit b912d88

Please sign in to comment.