You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.5 KiB

3 years ago
RUN apt-get update && \
apt-get install -y --no-install-recommends jq moreutils && \
rm -rf /var/lib/apt/lists/*
3 years ago
WORKDIR /frontend
COPY ./frontend/package.json ./frontend/yarn.lock ./
RUN yarn install --frozen-lockfile
COPY ./frontend ./
# If using environment variables (REACT_APP_*) to pass data in at build-time,
# sometimes the values end up in the library code bundles. This means that changing
# the verison (as below) would invalidate everyone's caches even if the actual code
# didn't change. To avoid this, resort to using a JSON file that is edited before build.
ARG version
RUN jq ".version = \"${version}\"" ./src/metadata.json | sponge ./src/metadata.json
3 years ago
RUN yarn build
3 years ago
FROM golang:1.15 as GO_BUILD
3 years ago
WORKDIR /codies
COPY ./go.mod ./go.sum ./
RUN go mod download
# Manually copying the required files to make this image's cache only include Go code.
COPY *.go ./
3 years ago
COPY ./internal ./internal
COPY --from=JS_BUILD /frontend/build ./frontend/build
RUN go run list && \
go run -o internal/pkger
ARG version
RUN go build -ldflags="-X${version}" .
3 years ago
# TODO: Use distroless/static and statically compile above. (
COPY --from=GO_BUILD /codies/codies /codies
ENTRYPOINT [ "/codies", "--prod" ]
3 years ago
# Verify that the binary works.
RUN [ "/codies", "version" ]