Skip to content

Commit

Permalink
Build and run api locally similarly to prod
Browse files Browse the repository at this point in the history
Unify api Dockerfile. There is no production Dockerfile (in prod this runs in a buildpack) so unify and simplify on one that matches the GitHub Action build process.

Don't mount local source code into the container.
  • Loading branch information
JuliusSkylerSladeUSDS committed Jan 22, 2025
1 parent 692c923 commit a723c61
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 47 deletions.
14 changes: 8 additions & 6 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ FROM node:14.21.3-alpine

WORKDIR /app

COPY package.json .
COPY package-lock.json .
COPY package*.json .

RUN npm install
RUN npm ci

COPY . ./app
COPY . .

# npm build:assets (invoked by build) expects src/client to exist, so create it.
RUN mkdir -p src/client
RUN npm run build

ENV PORT=9000
EXPOSE 9000

CMD ["npm", "start"]
CMD ["node", "./build/server.js"]
14 changes: 0 additions & 14 deletions api/Dockerfile.compose

This file was deleted.

17 changes: 0 additions & 17 deletions api/Dockerfile.dev

This file was deleted.

11 changes: 1 addition & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
version: "3.7"

services:
api:
container_name: api
build:
context: api
dockerfile: Dockerfile.compose
dockerfile: Dockerfile
environment:
- POSTGRES_URI=postgres://docker_pg_user:docker_pg_pw@db:5432/docker_db
- POSTGRES_DISABLE_SSL=true
- NODE_ENV=docker
- PORT=9000
- APP_ENV=docker
- ADMIN_TOKEN=admin
volumes:
- ./api:/opt/node_app/app
- ./db:/opt/node_app/db
- /opt/node_app/app/node_modules
ports:
- 9000:9000
- 9229:9229
Expand All @@ -35,9 +29,6 @@ services:
- REACT_APP_ENV=docker
- CHOKIDAR_USEPOLLING=true
- PORT=8000
volumes:
- /opt/react_app/node_modules
- ./frontend:/opt/react_app
ports:
- 8000:8000
expose:
Expand Down

0 comments on commit a723c61

Please sign in to comment.