mirror of
https://github.com/amigan/aim-oscar-server.git
synced 2025-02-28 10:22:35 -05:00
update dockerfile
This commit is contained in:
parent
f8f5378662
commit
3205129e73
1 changed files with 28 additions and 4 deletions
32
Dockerfile
32
Dockerfile
|
@ -1,13 +1,28 @@
|
||||||
FROM golang:1.17-alpine3.14 AS build
|
FROM golang:1.17-alpine3.14 AS build
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go.mod go.sum /app
|
COPY go.mod go.sum /app
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN go build -ldflags="-s -w" -o /app/aim
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /app/aim
|
||||||
RUN chmod +x /app/aim
|
RUN chmod +x /app/aim && chmod +rw /app/aim.db
|
||||||
|
|
||||||
FROM golang:1.17-alpine3.14 AS prod
|
FROM scratch AS prod
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -17,6 +32,15 @@ ARG OSCAR_PORT
|
||||||
ARG OSCAR_BOS_HOST
|
ARG OSCAR_BOS_HOST
|
||||||
ARG OSCAR_BOS_PORT
|
ARG OSCAR_BOS_PORT
|
||||||
|
|
||||||
|
# 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
|
||||||
COPY --from=build /app/models /app/models
|
COPY --from=build /app/models /app/models
|
||||||
COPY --from=build /app/aim /app/aim
|
COPY --from=build /app/aim /app/aim
|
||||||
CMD ["/app/aim"]
|
COPY --from=build /app/aim.db /app/aim.db
|
||||||
|
|
||||||
|
# Use an unprivileged user.
|
||||||
|
USER appuser:appuser
|
||||||
|
|
||||||
|
ENTRYPOINT ["/app/aim"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue