-
Notifications
You must be signed in to change notification settings - Fork 56
/
Dockerfile
45 lines (32 loc) · 1.18 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
FROM golang:1.22-alpine3.20 AS build
ARG APIFIREWALL_NAMESPACE
ARG APIFIREWALL_VERSION
ENV APIFIREWALL_NAMESPACE=${APIFIREWALL_NAMESPACE}
ENV APIFIREWALL_VERSION=${APIFIREWALL_VERSION}
RUN apk add --no-cache \
gcc \
git \
make \
musl-dev
WORKDIR /build
COPY . .
RUN go mod download -x && \
go build \
-ldflags="-X ${APIFIREWALL_NAMESPACE}/internal/version.Version=${APIFIREWALL_VERSION} -s -w" \
-buildvcs=false \
-o ./api-firewall \
./cmd/api-firewall
# Smoke test
RUN ./api-firewall -v
FROM alpine:3.20 AS composer
WORKDIR /output
COPY --from=build /build/api-firewall ./usr/local/bin/
COPY docker-entrypoint.sh ./usr/local/bin/docker-entrypoint.sh
RUN chmod 755 ./usr/local/bin/* && \
chown root:root ./usr/local/bin/*
FROM alpine:3.20
RUN adduser -u 1000 -H -h /opt -D -s /bin/sh api-firewall
COPY --from=composer /output /
USER api-firewall
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["api-firewall"]