Dockerfile

 1FROM node:14 AS JS_BUILD
 2WORKDIR /frontend
 3COPY ./frontend/package.json ./frontend/yarn.lock ./
 4RUN yarn install --frozen-lockfile
 5COPY ./frontend ./
 6RUN yarn build
 7
 8FROM golang:1.14 as GO_BUILD
 9WORKDIR /codies
10COPY ./go.mod ./go.sum ./
11RUN go mod download
12# Manually copying the required files to make this image's cache only include Go code.
13COPY ./main.go ./main.go
14COPY ./internal ./internal
15
16ARG version
17RUN go build  -ldflags="-X github.com/zikaeroh/codies/internal/version.version=${version}" .
18
19# TODO: Use distroless/static and statically compile above. (https://golang.org/issue/26492)
20FROM gcr.io/distroless/base:nonroot
21WORKDIR /codies
22COPY --from=GO_BUILD /codies/codies ./codies
23COPY --from=JS_BUILD /frontend/build ./frontend/build
24ENTRYPOINT [ "/codies/codies" ]
25EXPOSE 5000