flake plus docker cli metadata

This commit is contained in:
Jim Clark
2023-05-14 21:30:59 -07:00
parent ce5b1520f8
commit e504aafa11
4 changed files with 72 additions and 44 deletions

View File

@@ -1,20 +1,29 @@
FROM golang:1.19-alpine AS build
# syntax = docker/dockerfile:1.4
FROM nixos/nix:latest AS builder
WORKDIR /tmp/build
RUN mkdir /tmp/nix-store-closure
RUN \
--mount=type=cache,target=/nix,from=nixos/nix:latest,source=/nix \
--mount=type=cache,target=/root/.cache \
--mount=type=bind,target=/tmp/build \
<<EOF
ls -l /nix/store | wc
nix \
--extra-experimental-features "nix-command flakes" \
--extra-substituters "http://host.docker.internal?priority=10" \
--option filter-syscalls false \
--show-trace \
--log-format raw \
build . --out-link /tmp/output/result
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure
EOF
FROM scratch
WORKDIR /app
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY main.go ./
COPY docker/ ./docker/
COPY babashka/ ./babashka/
RUN CGO_ENABLED=0 go build -ldflags "-s -w" -o babashka-pod-docker
FROM alpine:3.17
ARG version
COPY repository/ /root/.babashka/pods/repository
COPY --from=build /app/babashka-pod-docker /root/.babashka/pods/repository/docker/babashka-pod-docker/0.1.0
RUN chmod 755 /root/.babashka/pods/repository/docker/babashka-pod-docker/0.1.0/babashka-pod-docker
COPY --from=builder /tmp/nix-store-closure /nix/store
COPY --from=builder /tmp/output/ /app/
ENTRYPOINT ["/app/result/bin/babashka-pod-docker"]