Skip to content

Commit

Permalink
feat(be): optimize Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
harisato committed Jul 14, 2023
1 parent 6aec80d commit e5b8b9d
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
FROM node:18.16 AS build-stage
FROM node:lts-alpine AS build-stage
WORKDIR /usr/src/app/
COPY package.json ./
COPY package.json yarn.lock ./

RUN yarn install
RUN yarn install --ignore-scripts

COPY . .
COPY ./src ./src
COPY ./*.json ./

# COPY ./src ./src
# COPY ./*.json ./
RUN yarn build:prod

# RUN yarn build:prod

# FROM node:18.16-alpine AS install-dependencies-stage
# WORKDIR /usr/src/app/
# COPY package.json yarn.lock ./
FROM node:lts-alpine AS install-dependencies-stage
WORKDIR /usr/src/app/
COPY package.json yarn.lock ./

# RUN yarn install --prod --ignore-scripts
RUN yarn install --prod --ignore-scripts

# # Run-time stage
# FROM node:18.16-alpine AS run-stage
# USER node
# ARG PORT=3000
# Run-time stage
FROM node:lts-alpine AS run-stage
USER node
ARG PORT=3000

# WORKDIR /usr/src/app/
WORKDIR /usr/src/app/

# COPY --from=build-stage /usr/src/app/dist ./dist
# COPY --from=install-dependencies-stage /usr/src/app/node_modules ./node_modules
# COPY . /usr/src/app/
COPY --from=build-stage /usr/src/app/dist ./dist
COPY --from=install-dependencies-stage /usr/src/app/node_modules ./node_modules
COPY *.json /usr/src/app/

EXPOSE 3000
CMD [ "yarn", "start" ]
# CMD [ "tail", "-f","/dev/null" ]
EXPOSE $PORT
CMD [ "yarn", "start:prod" ]

0 comments on commit e5b8b9d

Please sign in to comment.