oliverdavies.uk/Dockerfile

39 lines
598 B
Docker
Raw Normal View History

2022-10-07 08:14:10 +00:00
FROM node:14-bullseye-slim AS base
ARG NODE_ENV="production"
ARG SCULPIN_ENV="prod"
ENV NODE_ENV="${NODE_ENV}" \
PATH="${PATH}:/node_modules/.bin" \
USER="node"
2022-10-07 08:14:10 +00:00
WORKDIR /app
RUN mkdir -p /node_modules \
&& chown node:node -R /app /node_modules
2022-10-07 08:14:10 +00:00
###
FROM base AS build
USER node
2022-10-07 08:14:10 +00:00
COPY --chown=node:node *yarn* package.json ./
RUN yarn install && yarn cache clean
2022-10-07 08:14:10 +00:00
COPY --chown=node:node . .
RUN if [ "${NODE_ENV}" != "development" ]; then \
2022-10-07 08:14:10 +00:00
yarn build; \
else mkdir -p /app/build; fi
CMD ["bash"]
###
FROM alpine AS production
2022-10-07 08:14:10 +00:00
COPY --from=build /app/dist /app
2022-10-07 08:14:10 +00:00
CMD ["bash"]