Skip to content

debugging locally reproducing production error

Carlo Beltrame edited this page Nov 9, 2022 · 7 revisions

Locally reproducing an error that only appears on a deployment

First, locally build the container in which the problem happens. E.g. for frontend:

docker build -t ecamp/ecamp3-frontend:dev -f .docker-hub/frontend/Dockerfile .

💡 See the various "build and push" jobs in the continuous deployment workflow to find the exact parameters for other containers.

Then, modify docker-compose.yml to use your built image instead of the normal one in use during development:

 services:
   frontend:
-    image: node:18.12.0@sha256:cef9966b19672effeafcf1a67b8add742c3e46ca7dd5532efff60820526c2e95
+    image: ecamp/ecamp3-frontend:dev
     container_name: 'ecamp3-frontend'
     ports:
       - '3000:3000'
       - '9229:9229' # jest debug
     stdin_open: true
     tty: true
-    user: ${USER_ID:-1000}
     volumes:
       - ./.prettierrc:/.prettierrc
       - ./frontend:/app:delegated
       - ./common:/common:delegated
       - ./.cache/npm:/home/node/.npm
       - ./.cache/cypress:/home/node/.cache/Cypress
-    command: ./docker-setup.sh
     working_dir: /app
     environment:

💡 Make sure to remove the user: line, because on the deployment, currently all containers run as root.

Finally, run the project normally using docker-compose up.

After adjusting code, you need to rebuild the container image using the docker build command from above again, and then replace the running container with a new one:

docker-compose stop frontend && docker-compose up -d --no-deps frontend

This will take some time and manual effort on every code change, which is the reason we normally use a completely separate development setup with hot reloading.