apiary/Dockerfile
2021-11-06 00:56:15 +01:00

30 lines
968 B
Docker

FROM node:latest as frontend-builder
RUN mkdir -p /app/frontend
COPY web/frontend/yarn.lock /app/frontend/yarn.lock
COPY web/frontend/package.json /app/frontend/package.json
WORKDIR /app/frontend
RUN yarn install
COPY web/frontend /app/frontend
WORKDIR /app/frontend
RUN GENERATE_SOURCEMAP=false yarn build
FROM golang:latest as builder
WORKDIR /app
COPY go.mod /app/go.mod
COPY go.sum /app/go.sum
RUN go mod download
COPY . /app
RUN rm -rf /app/server/frontend
COPY --from=frontend-builder /app/frontend/dist /app/web/frontend/dist
RUN CGO_ENABLED=0 INSTALL_PREFIX=/app make install
FROM alpine:latest
RUN apk add --no-cache curl
WORKDIR /app
COPY --from=builder /app/etc/apiary/apiary.toml /app/apiary.toml
COPY --from=builder /app/bin/apiary /app/apiary
EXPOSE 8080
EXPOSE 2222
HEALTHCHECK --interval=1m --timeout=10s --start-period=5s --retries=3 CMD curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8080/api/health || exit 1
CMD ["/app/apiary", "serve"]