Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
ARG GO_VERSION=1.17
FROM golang:${GO_VERSION}-alpine as build

# empty dir and /etc/passwd file to run transfer with unprivileged user
RUN install -g nobody -o nobody -m 0770 -d /tmp/empty-dir-owned-by-nobody
RUN echo 'nobody:x:65534:65534:nobody:/:/sbin/nologin' > /tmp/passwd

# Necessary to run 'go get' and to compile the linked binary
RUN apk add git musl-dev

Expand All @@ -17,9 +21,12 @@ RUN CGO_ENABLED=0 go build -tags netgo -ldflags "-X github.com/dutchcoders/trans
FROM scratch AS final
LABEL maintainer="Andrea Spacca <andrea.spacca@gmail.com>"

COPY --chown=65534:65534 --from=build /tmp/empty-dir-owned-by-nobody /tmp
COPY --from=build /tmp/passwd /etc/passwd
COPY --from=build /go/bin/transfersh /go/bin/transfersh
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

USER nobody
ENTRYPOINT ["/go/bin/transfersh", "--listener", ":8080"]

EXPOSE 8080