-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.dev
34 lines (22 loc) · 937 Bytes
/
Dockerfile.dev
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
ARG GOLANG_VERSION
FROM golang:${GOLANG_VERSION}
ARG SERVICE_NAME
WORKDIR /${SERVICE_NAME}
# -- DinD
COPY --from=docker:dind-rootless --chown=nobody:nogroup /usr/local/bin/docker /usr/local/bin
# -- install 3rd-party
ARG TARGETOS TARGETARCH K6_VERSION
# air
RUN --mount=target=. --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg GOOS=$TARGETOS GOARCH=$TARGETARCH go install github.com/cosmtrek/[email protected]
# k6
ADD https://github.com/grafana/k6/releases/download/v${K6_VERSION}/k6-v${K6_VERSION}-linux-$TARGETARCH.tar.gz k6-v${K6_VERSION}-linux-$TARGETARCH.tar.gz
RUN tar -xf k6-v${K6_VERSION}-linux-$TARGETARCH.tar.gz --strip-components 1 -C /usr/bin
# -- set up Go
COPY . .
RUN go mod download
RUN chown -R nobody:nogroup /${SERVICE_NAME}
RUN chown -R nobody:nogroup /go
ENV GOCACHE /go/.cache/go-build
ENV GOENV /go/.config/go/env
USER nobody:nogroup
ENTRYPOINT ["tail", "-f", "/dev/null"]