1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- # syntax=docker/dockerfile:1
- ARG GO_VERSION=1.23.8
- ARG ALPINE_VERSION=3.21
- # BUILDX_VERSION sets the version of buildx to install in the dev container.
- # It must be a valid tag in the docker.io/docker/buildx-bin image repository
- # on Docker Hub.
- ARG BUILDX_VERSION=0.23.0
- FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
- FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golang
- ENV GOTOOLCHAIN=local
- ENV CGO_ENABLED=0
- FROM golang AS gofumpt
- ARG GOFUMPT_VERSION=v0.7.0
- RUN --mount=type=cache,target=/root/.cache/go-build \
- --mount=type=cache,target=/go/pkg/mod \
- --mount=type=tmpfs,target=/go/src/ \
- GO111MODULE=on go install "mvdan.cc/gofumpt@${GOFUMPT_VERSION}" \
- && gofumpt --version
- FROM golang AS gotestsum
- ARG GOTESTSUM_VERSION=v1.12.0
- RUN --mount=type=cache,target=/root/.cache/go-build \
- --mount=type=cache,target=/go/pkg/mod \
- --mount=type=tmpfs,target=/go/src/ \
- GO111MODULE=on go install gotest.tools/gotestsum@${GOTESTSUM_VERSION}
- FROM golang AS goversioninfo
- ARG GOVERSIONINFO_VERSION=v1.4.1
- RUN --mount=type=cache,target=/root/.cache/go-build \
- --mount=type=cache,target=/go/pkg/mod \
- --mount=type=tmpfs,target=/go/src/ \
- GO111MODULE=on go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}
- FROM golang AS dev
- RUN apk add --no-cache \
- bash \
- bash-completion \
- build-base \
- ca-certificates \
- coreutils \
- curl \
- git \
- jq \
- nano
- RUN <<-'EOF'
- cat > /etc/motd <<-'EOM'
- \e[1;32mYou are now in a development container.\e[0m
- Run \e[1;36mmake help\e[0m to see available targets.
- EOM
- cat >> /root/.bashrc <<-'EOB'
- # print the MOTD when opening the dev-container (interactive shell only).
- if [[ $- == *i* ]] && [[ -z "$MOTD_SHOWN" ]]; then
- printf "%b\n" "$(cat /etc/motd)"
- export MOTD_SHOWN=1
- fi
- # set a custom prompt to make it more visible when inside the dev-container.
- PS1='\[\e[0;32m\]\u@docker-cli-dev\$ \[\e[0m\]'
- # set-up bash completion for testing.
- source /etc/bash/bash_completion.sh
- EOB
- EOF
- CMD ["/bin/bash"]
- ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
- ENV PATH=$PATH:/go/src/github.com/docker/cli/build
- COPY --link --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
- COPY --link --from=gofumpt /go/bin/* /go/bin/
- COPY --link --from=gotestsum /go/bin/* /go/bin/
- COPY --link --from=goversioninfo /go/bin/* /go/bin/
- WORKDIR /go/src/github.com/docker/cli
- ENV GO111MODULE=auto
- COPY --link . .
|