-
Notifications
You must be signed in to change notification settings - Fork 66
/
Dockerfile
44 lines (34 loc) · 972 Bytes
/
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
#################
# Builder Image #
#################
FROM golang:1.18.8-alpine3.16 as builder
WORKDIR /go/src/oidc-authservice
# Download all dependencies
COPY go.mod .
COPY go.sum .
RUN go mod download
# Copy in the code and compile
COPY *.go ./
COPY common common
COPY oidc oidc
COPY sessions sessions
COPY authenticators authenticators
RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o /go/bin/oidc-authservice
#################
# Release Image #
#################
FROM alpine:3.16
RUN apk add --no-cache ca-certificates
ENV USER=authservice
ENV GROUP=authservice
# Add new user to run as
RUN addgroup -S -g 111 $GROUP && adduser -S -G $GROUP $USER
ENV APP_HOME=/home/$USER
WORKDIR $APP_HOME
# Copy in binary and give permissions
COPY --from=builder /go/bin/oidc-authservice $APP_HOME
COPY web $APP_HOME/web
RUN chmod +x $APP_HOME/oidc-authservice
RUN chown -R $USER:$GROUP $APP_HOME
USER $USER
ENTRYPOINT [ "./oidc-authservice" ]