Listory/Dockerfile

60 lines
1.2 KiB
Text
Raw Normal View History

2020-01-26 19:07:15 +01:00
##################
## common
##################
2020-05-02 17:17:20 +02:00
FROM node:14-alpine as common
ARG VERSION=unknown
ARG GIT_COMMIT=unknown
LABEL org.opencontainers.image.title="listory" \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.revision=$GIT_COMMIT \
stage="common"
2020-01-26 19:07:15 +01:00
2020-01-25 22:19:14 +01:00
WORKDIR /app
2020-01-26 19:07:15 +01:00
2020-01-25 22:19:14 +01:00
COPY *.json /app/
2020-01-26 19:07:15 +01:00
COPY frontend/*.json /app/frontend/
2020-01-25 22:19:14 +01:00
2020-01-26 19:07:15 +01:00
##################
## build-api
##################
FROM common as build-api
LABEL stage="build-api"
2020-01-25 22:19:14 +01:00
RUN npm ci
COPY src/ /app/src/
RUN NODE_ENV=production npm run build
2020-01-25 22:19:14 +01:00
2020-01-26 19:07:15 +01:00
##################
## build-frontend
##################
FROM common as build-frontend
LABEL stage="build-frontend"
ARG VERSION=unknown
2020-01-26 19:07:15 +01:00
WORKDIR /app/frontend
RUN npm ci
COPY frontend/postcss.config.js /app/frontend/postcss.config.js
COPY frontend/tailwind.config.js /app/frontend/tailwind.config.js
2020-01-26 19:07:15 +01:00
COPY frontend/src/ /app/frontend/src/
COPY frontend/public/ /app/frontend/public/
COPY frontend/.env.production /app/frontend/.env.production
RUN NODE_ENV=production npm run build
2020-01-25 22:19:14 +01:00
2020-01-26 19:07:15 +01:00
##################
## app
##################
2020-01-25 22:19:14 +01:00
FROM common as app
LABEL stage="app"
RUN npm ci --only=production
2020-01-26 19:07:15 +01:00
COPY --from=build-api /app/dist/ /app/dist/
COPY --from=build-frontend /app/frontend/build /app/static/
2020-01-25 22:19:14 +01:00
CMD ["dist/main"]