You've already forked speedtest-go
Make Docker image easier to use (#50)
* Use single server example as default frontend This just works out of the box * Refactor Dockerfile - Remove the asset dir since it's embedded in the executable anyway - Use the code in the current directory to build instead of downloading. Makes local testing very easy. - Cache Go dependencies - Run without root privileges. Note that using a BoltDB database requires mounting a volume with the correct permissions. The default database has thus been changed to memory so that starting the image just works. * Automatically publish images
This commit is contained in:
26
Dockerfile
26
Dockerfile
@ -1,20 +1,18 @@
|
||||
FROM golang:alpine AS build_base
|
||||
#ENV GOARCH arm64
|
||||
#ENV GOARCH amd64
|
||||
RUN apk add --no-cache git gcc ca-certificates libc-dev \
|
||||
&& mkdir -p /go/src/github.com/librespeed/ \
|
||||
&& cd /go/src/github.com/librespeed/ \
|
||||
&& git clone https://github.com/librespeed/speedtest-go.git
|
||||
WORKDIR /go/src/github.com/librespeed/speedtest-go
|
||||
RUN go get ./ && go build -ldflags "-w -s" -trimpath -o speedtest main.go
|
||||
FROM golang:1.18-alpine AS build_base
|
||||
RUN apk add --no-cache git gcc ca-certificates libc-dev
|
||||
WORKDIR /build
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY ./ ./
|
||||
RUN go build -ldflags "-w -s" -trimpath -o speedtest .
|
||||
|
||||
FROM alpine:3.15
|
||||
RUN apk add ca-certificates
|
||||
FROM alpine:3.16
|
||||
RUN apk add --no-cache ca-certificates
|
||||
WORKDIR /app
|
||||
COPY --from=build_base /go/src/github.com/librespeed/speedtest-go/speedtest .
|
||||
COPY --from=build_base /go/src/github.com/librespeed/speedtest-go/web/assets ./assets
|
||||
COPY --from=build_base /go/src/github.com/librespeed/speedtest-go/settings.toml .
|
||||
COPY --from=build_base /build/speedtest ./
|
||||
COPY settings.toml ./
|
||||
|
||||
USER nobody
|
||||
EXPOSE 8989
|
||||
|
||||
CMD ["./speedtest"]
|
||||
|
Reference in New Issue
Block a user