diff --git a/Dockerfile b/Dockerfile index f22c054..d790166 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Use a multi-stage build for efficiency FROM node:20 AS builder -WORKDIR /usr/src/app +WORKDIR /app COPY package*.json ./ @@ -15,16 +15,24 @@ RUN npm run build # Production stage FROM node:20 -WORKDIR /usr/src/app +WORKDIR /app -COPY --from=builder /usr/src/app/dist ./dist +COPY --from=builder /app/dist ./dist COPY package*.json ./ COPY ./lua ./lua +COPY ./scripts/docker-entrypoint.sh ./ +RUN chmod +x ./docker-entrypoint.sh -RUN npm install --only=production +RUN npm ci --omit=dev + +# We want jq and curl in the final image, but we don't need the support files +RUN apt-get update && \ + apt-get install -y jq curl tini && \ + apt-get clean && \ + rm -rf /usr/share/doc /usr/share/man /usr/share/zsh EXPOSE 3000 ENV START_PROCESS="api" -ENTRYPOINT ["npm", "run", "start:${START_PROCESS}:prod"] +ENTRYPOINT ["/usr/bin/tini", "--", "./docker-entrypoint.sh"] diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index c014cf4..32db1a0 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -1,5 +1,3 @@ -version: '3' - services: redis: image: redis:latest diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh new file mode 100755 index 0000000..6a8cad5 --- /dev/null +++ b/scripts/docker-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# Wrapper script to launch the containerized app because we need to parse the environment +exec npm run start:${START_PROCESS}:prod -- $@