aim-oscar-server/Dockerfile

46 lines
990 B
Text
Raw Normal View History

2021-12-24 15:17:07 -05:00
FROM golang:1.17-alpine3.14 AS build
2021-12-24 13:38:22 -05:00
2021-12-25 22:52:40 -05:00
RUN apk update && apk add --no-cache git ca-certificates && update-ca-certificates
# Create appuser
ENV USER=appuser
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
2021-12-24 15:17:07 -05:00
WORKDIR /app
2021-12-27 16:15:47 -05:00
COPY go.mod go.sum /app/
2021-12-24 15:48:36 -05:00
RUN go mod download
2021-12-24 15:17:07 -05:00
COPY . /app
2021-12-25 22:52:40 -05:00
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /app/aim
2022-01-16 16:39:44 -05:00
RUN chmod +x /app/aim
2021-12-24 15:48:36 -05:00
2021-12-25 22:52:40 -05:00
FROM scratch AS prod
2021-12-24 15:17:07 -05:00
2021-12-24 15:48:36 -05:00
WORKDIR /app
2021-12-24 13:38:22 -05:00
EXPOSE 5190
ARG OSCAR_HOST
ARG OSCAR_PORT
ARG OSCAR_BOS_HOST
ARG OSCAR_BOS_PORT
2021-12-25 22:52:40 -05:00
# Import from builder.
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /etc/group /etc/group
2021-12-24 15:48:36 -05:00
COPY --from=build /app/models /app/models
2021-12-24 15:17:07 -05:00
COPY --from=build /app/aim /app/aim
2021-12-25 22:52:40 -05:00
# Use an unprivileged user.
USER appuser:appuser
ENTRYPOINT ["/app/aim"]