2022-07-12 10:09:52 +00:00
|
|
|
# syntax=docker/dockerfile:1.4
|
|
|
|
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:1.18 AS build
|
2020-04-07 19:32:26 +00:00
|
|
|
|
|
|
|
WORKDIR /compose/hello-docker
|
|
|
|
COPY main.go main.go
|
|
|
|
RUN CGO_ENABLED=0 go build -o backend main.go
|
|
|
|
|
2022-07-12 10:09:52 +00:00
|
|
|
FROM build as dev-envs
|
|
|
|
|
|
|
|
RUN <<EOF
|
|
|
|
apt-get update
|
|
|
|
apt-get install -y --no-install-recommends git
|
|
|
|
EOF
|
|
|
|
|
|
|
|
RUN <<EOF
|
|
|
|
useradd -s /bin/bash -m vscode
|
|
|
|
groupadd docker
|
|
|
|
usermod -aG docker vscode
|
|
|
|
EOF
|
|
|
|
# install Docker tools (cli, buildx, compose)
|
|
|
|
COPY --from=gloursdocker/docker / /
|
|
|
|
CMD ["go", "run", "main.go"]
|
|
|
|
|
2020-04-07 19:32:26 +00:00
|
|
|
FROM scratch
|
|
|
|
COPY --from=build /compose/hello-docker/backend /usr/local/bin/backend
|
|
|
|
CMD ["/usr/local/bin/backend"]
|
|
|
|
|
|
|
|
|