diff --git a/Dockerfile b/Dockerfile index 539e264..fa9274d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,21 @@ -FROM node:20.19-slim AS BUILD_IMAGE - -WORKDIR /app - -COPY . /app - -RUN yarn install --registry https://registry.npmmirror.com/ --ignore-engines && yarn run build - FROM node:20.19-slim -COPY --from=BUILD_IMAGE /app/configs /app/configs -COPY --from=BUILD_IMAGE /app/package.json /app/package.json -COPY --from=BUILD_IMAGE /app/dist /app/dist -COPY --from=BUILD_IMAGE /app/public /app/public -COPY --from=BUILD_IMAGE /app/node_modules /app/node_modules - WORKDIR /app +# Copy application dependency manifests to the container image. +# A wildcard is used to ensure both package.json AND package-lock.json are copied. +# Copying this first prevents re-running npm install on every code change. +COPY package*.json ./ + +# Install dependencies +RUN yarn install --registry https://registry.npmmirror.com/ --ignore-engines + +# Copy the rest of the application files to the container image. +COPY . . + +# Build the application +RUN yarn run build + EXPOSE 3302 CMD ["npm", "start"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c233acf..d188319 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,7 @@ services: build: context: ./ dockerfile: Dockerfile + image: jimeng-free-api:latest container_name: jimeng-free-api volumes: - ./:/app