File: Dockerfile.dev

package info (click to toggle)
docker.io 28.5.2%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 69,048 kB
  • sloc: sh: 5,867; makefile: 863; ansic: 184; python: 162; asm: 159
file content (90 lines) | stat: -rw-r--r-- 2,945 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# syntax=docker/dockerfile:1

ARG GO_VERSION=1.24.9

# ALPINE_VERSION sets the version of the alpine base image to use, including for the golang image.
# It must be a supported tag in the docker.io/library/alpine image repository
# that's also available as alpine image variant for the Golang version used.
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.25.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
# GOTESTSUM_VERSION sets the version of gotestsum to install in the dev container.
# It must be a valid tag in the https://github.com/gotestyourself/gotestsum repository.
ARG GOTESTSUM_VERSION=v1.13.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 \
    git-daemon \
    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 . .