Dockerfile: Added build arg, RELEASE.

This allows you to build a debug version of commento and deploy to docker. Useful when debugging a containered version of commento.
This commit is contained in:
Drew Foehn 2020-07-18 20:23:28 -04:00 committed by Adhityaa Chandrasekar
parent 800902640b
commit 84bfd64e32

View File

@ -2,45 +2,50 @@
FROM golang:1.15-alpine AS api-build
RUN apk add --no-cache --update bash dep make git curl g++
ARG RELEASE=prod
COPY ./api /go/src/commento/api/
WORKDIR /go/src/commento/api
RUN make prod -j$(($(nproc) + 1))
RUN make ${RELEASE} -j$(($(nproc) + 1))
# frontend build (html, js, css, images)
FROM node:12-alpine AS frontend-build
RUN apk add --no-cache --update bash make python2 g++
ARG RELEASE=prod
COPY ./frontend /commento/frontend
WORKDIR /commento/frontend/
RUN make prod -j$(($(nproc) + 1))
RUN make ${RELEASE} -j$(($(nproc) + 1))
# templates and db build
FROM alpine:3.13 AS templates-db-build
RUN apk add --no-cache --update bash make
ARG RELEASE=prod
COPY ./templates /commento/templates
WORKDIR /commento/templates
RUN make prod -j$(($(nproc) + 1))
RUN make ${RELEASE} -j$(($(nproc) + 1))
COPY ./db /commento/db
WORKDIR /commento/db
RUN make prod -j$(($(nproc) + 1))
RUN make ${RELEASE} -j$(($(nproc) + 1))
# final image
FROM alpine:3.13
RUN apk add --no-cache --update ca-certificates
COPY --from=api-build /go/src/commento/api/build/prod/commento /commento/commento
COPY --from=frontend-build /commento/frontend/build/prod/js /commento/js
COPY --from=frontend-build /commento/frontend/build/prod/css /commento/css
COPY --from=frontend-build /commento/frontend/build/prod/images /commento/images
COPY --from=frontend-build /commento/frontend/build/prod/fonts /commento/fonts
COPY --from=frontend-build /commento/frontend/build/prod/*.html /commento/
COPY --from=templates-db-build /commento/templates/build/prod/templates /commento/templates/
COPY --from=templates-db-build /commento/db/build/prod/db /commento/db/
ARG RELEASE=prod
COPY --from=api-build /go/src/commento/api/build/${RELEASE}/commento /commento/commento
COPY --from=frontend-build /commento/frontend/build/${RELEASE}/js /commento/js
COPY --from=frontend-build /commento/frontend/build/${RELEASE}/css /commento/css
COPY --from=frontend-build /commento/frontend/build/${RELEASE}/images /commento/images
COPY --from=frontend-build /commento/frontend/build/${RELEASE}/fonts /commento/fonts
COPY --from=frontend-build /commento/frontend/build/${RELEASE}/*.html /commento/
COPY --from=templates-db-build /commento/templates/build/${RELEASE}/templates /commento/templates/
COPY --from=templates-db-build /commento/db/build/${RELEASE}/db /commento/db/
EXPOSE 8080
WORKDIR /commento/