commento/Dockerfile

49 lines
1.5 KiB
Docker
Raw Normal View History

# backend build (api server)
2020-09-05 07:05:37 +08:00
FROM golang:1.15-alpine AS api-build
2020-02-10 00:39:29 +08:00
RUN apk add --no-cache --update bash dep make git curl g++
COPY ./api /go/src/commento/api/
2018-12-29 01:41:45 +08:00
WORKDIR /go/src/commento/api
RUN make prod -j$(($(nproc) + 1))
# frontend build (html, js, css, images)
2020-09-05 07:05:37 +08:00
FROM node:12-alpine AS frontend-build
2020-02-10 00:39:29 +08:00
RUN apk add --no-cache --update bash make python2 g++
COPY ./frontend /commento/frontend
2018-12-29 01:41:45 +08:00
WORKDIR /commento/frontend/
RUN make prod -j$(($(nproc) + 1))
# templates and db build
2020-09-05 07:05:37 +08:00
FROM alpine:3.13 AS templates-db-build
RUN apk add --no-cache --update bash make
2018-12-29 01:41:45 +08:00
COPY ./templates /commento/templates
WORKDIR /commento/templates
RUN make prod -j$(($(nproc) + 1))
2018-12-29 01:41:45 +08:00
COPY ./db /commento/db
WORKDIR /commento/db
RUN make prod -j$(($(nproc) + 1))
# final image
2020-09-05 07:05:37 +08:00
FROM alpine:3.13
RUN apk add --no-cache --update ca-certificates
2018-12-29 01:41:45 +08:00
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
2018-12-29 01:41:45 +08:00
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/
EXPOSE 8080
2018-12-29 01:41:45 +08:00
WORKDIR /commento/
ENV COMMENTO_BIND_ADDRESS="0.0.0.0"
2018-12-29 01:41:45 +08:00
ENTRYPOINT ["/commento/commento"]