forked from peterldowns/nix-search-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (38 loc) · 1.25 KB
/
Dockerfile
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
# Build Stage
# Pin to the latest minor version without specifying a patch version so that
# we always deploy security fixes as soon as they are available.
FROM golang:1.18-alpine as builder
# Have to put our source in the right place for it to build
WORKDIR $GOPATH/src/github.com/peterldowns/nix-search-cli
ENV GO111MODULE=on
ENV CGO_ENABLED=0
# Install the dependencies
COPY go.mod .
COPY go.sum .
RUN go mod download
# Build the application
COPY . .
# Put the appropriate build artifacts in a folder for distribution
RUN mkdir -p /dist
RUN go build -o /dist/nix-search ./cmd/nix-search
# App Stage
FROM alpine:3.16.3 as app
LABEL org.opencontainers.image.source="https://github.com/peterldowns/nix-search-cli"
LABEL org.opencontainers.image.description="nix-search"
LABEL org.opencontainers.image.licenses="MIT"
# Add a non-root user and group with appropriate permissions
# and consistent ids.
RUN addgroup --gid 888 --system app && \
adduser --no-create-home \
--gecos "" \
--shell "/bin/ash" \
--uid 999 \
--ingroup app \
--system \
app
USER app
WORKDIR /app
ARG COMMIT_SHA=null
ENV COMMIT_SHA=$COMMIT_SHA
COPY --from=builder --chown=app:app /dist /app
ENTRYPOINT ["/app/nix-search"]