2019-01-04 21:40:22 +00:00
|
|
|
FROM golang:1.7-alpine AS builder
|
2017-05-29 21:21:53 +00:00
|
|
|
|
|
|
|
# Copy in the git repo from the build context
|
|
|
|
COPY . /go/src/github.com/tus/tusd/
|
|
|
|
|
|
|
|
# Create app directory
|
2019-01-04 21:40:22 +00:00
|
|
|
WORKDIR /go/src/github.com/tus/tusd
|
2017-05-29 21:21:53 +00:00
|
|
|
|
2019-01-04 21:40:22 +00:00
|
|
|
RUN apk add --no-cache \
|
2017-05-29 21:21:53 +00:00
|
|
|
git \
|
|
|
|
&& go get -d -v ./... \
|
|
|
|
&& version="$(git tag -l --points-at HEAD)" \
|
|
|
|
&& commit=$(git log --format="%H" -n 1) \
|
|
|
|
&& GOOS=linux GOARCH=amd64 go build \
|
|
|
|
-ldflags="-X github.com/tus/tusd/cmd/tusd/cli.VersionName=${version} -X github.com/tus/tusd/cmd/tusd/cli.GitCommit=${commit} -X 'github.com/tus/tusd/cmd/tusd/cli.BuildDate=$(date --utc)'" \
|
|
|
|
-o "/go/bin/tusd" ./cmd/tusd/main.go \
|
|
|
|
&& rm -r /go/src/* \
|
|
|
|
&& apk del git
|
|
|
|
|
2019-01-04 21:40:22 +00:00
|
|
|
# start a new stage that copies in the binary built in the previous stage
|
|
|
|
FROM alpine:3.8
|
|
|
|
|
|
|
|
COPY --from=builder /go/bin/tusd /usr/local/bin/tusd
|
|
|
|
|
2019-03-30 17:16:53 +00:00
|
|
|
RUN apk add --no-cache ca-certificates jq \
|
2019-01-13 23:08:03 +00:00
|
|
|
&& addgroup -g 1000 tusd \
|
2019-01-04 21:40:22 +00:00
|
|
|
&& adduser -u 1000 -G tusd -s /bin/sh -D tusd \
|
|
|
|
&& mkdir -p /srv/tusd-hooks \
|
|
|
|
&& mkdir -p /srv/tusd-data \
|
|
|
|
&& chown tusd:tusd /srv/tusd-data
|
|
|
|
|
2017-05-29 21:21:53 +00:00
|
|
|
WORKDIR /srv/tusd-data
|
|
|
|
EXPOSE 1080
|
2019-01-04 21:40:22 +00:00
|
|
|
ENTRYPOINT ["tusd"]
|
|
|
|
CMD ["--hooks-dir","/srv/tusd-hooks"]
|