2019-08-19 20:21:48 -08:00
|
|
|
FROM golang:1.12.9-alpine3.9 AS build_base_golang
|
2019-05-23 19:40:29 -05:00
|
|
|
|
|
|
|
LABEL maintainer="lee@geeksinthewoods.com"
|
|
|
|
|
|
|
|
RUN apk --update --no-cache add \
|
|
|
|
git
|
|
|
|
|
2019-06-25 02:40:29 -08:00
|
|
|
# Change dir to project base.
|
2019-07-13 12:16:28 -08:00
|
|
|
WORKDIR $GOPATH/src/gitlab.com/geeks-accelerator/oss/saas-starter-kit
|
2019-05-23 19:40:29 -05:00
|
|
|
|
2019-06-25 02:40:29 -08:00
|
|
|
# Enable go modules.
|
2019-05-23 19:40:29 -05:00
|
|
|
ENV GO111MODULE="on"
|
|
|
|
COPY go.mod .
|
|
|
|
COPY go.sum .
|
|
|
|
RUN go mod download
|
2019-08-12 12:30:35 -08:00
|
|
|
RUN go get github.com/pilu/fresh
|
2019-05-23 19:40:29 -05:00
|
|
|
|
2019-08-12 12:30:35 -08:00
|
|
|
FROM build_base_golang AS dev
|
2019-05-23 19:40:29 -05:00
|
|
|
|
2019-08-07 17:49:21 -08:00
|
|
|
ARG service
|
|
|
|
ARG commit_ref=-
|
|
|
|
|
2019-06-25 02:40:29 -08:00
|
|
|
# Copy shared packages.
|
2019-05-23 19:40:29 -05:00
|
|
|
COPY internal ./internal
|
|
|
|
|
2019-06-25 02:40:29 -08:00
|
|
|
# Copy cmd specific packages.
|
2019-08-12 12:30:35 -08:00
|
|
|
COPY cmd/${service} ./cmd/${service}
|
2019-08-07 17:49:21 -08:00
|
|
|
COPY cmd/${service}/templates /templates
|
|
|
|
COPY cmd/${service}/static /static
|
2019-05-23 19:40:29 -05:00
|
|
|
|
2019-08-02 15:03:32 -08:00
|
|
|
# Copy the global templates.
|
|
|
|
ADD resources/templates/shared /templates/shared
|
2019-08-12 12:30:35 -08:00
|
|
|
ADD fresh-auto-reload.conf /runner.conf
|
2019-08-02 15:03:32 -08:00
|
|
|
|
2019-08-12 21:28:16 -08:00
|
|
|
ENV TEMPLATE_DIR=/templates
|
|
|
|
|
2019-08-07 17:49:21 -08:00
|
|
|
WORKDIR ./cmd/${service}
|
2019-05-23 19:40:29 -05:00
|
|
|
|
2019-08-12 12:30:35 -08:00
|
|
|
ENTRYPOINT ["fresh", "-c", "/runner.conf"]
|
|
|
|
|
|
|
|
FROM dev AS builder
|
|
|
|
|
2019-08-07 17:49:21 -08:00
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.build=${commit_ref}" -a -installsuffix nocgo -o /gosrv .
|
2019-05-23 19:40:29 -05:00
|
|
|
|
|
|
|
FROM alpine:3.9
|
|
|
|
|
|
|
|
RUN apk --update --no-cache add \
|
|
|
|
tzdata ca-certificates curl openssl
|
|
|
|
|
|
|
|
COPY --from=builder /gosrv /
|
|
|
|
COPY --from=builder /static /static
|
|
|
|
COPY --from=builder /templates /templates
|
|
|
|
|
2019-07-10 00:17:35 -08:00
|
|
|
ENV TEMPLATE_DIR=/templates
|
2019-08-02 15:03:32 -08:00
|
|
|
ENV SHARED_TEMPLATE_DIR=/templates/shared
|
2019-07-14 19:13:09 -08:00
|
|
|
ENV STATIC_DIR=/static
|
2019-07-10 00:17:35 -08:00
|
|
|
|
2019-07-07 12:52:55 -08:00
|
|
|
ARG service
|
|
|
|
ENV SERVICE_NAME $service
|
|
|
|
|
|
|
|
ARG env="dev"
|
|
|
|
ENV ENV $env
|
|
|
|
|
2019-05-25 08:26:37 -05:00
|
|
|
ARG gogc="20"
|
2019-05-23 19:40:29 -05:00
|
|
|
ENV GOGC $gogc
|
|
|
|
|
|
|
|
ENTRYPOINT ["/gosrv"]
|