Dockerfile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Start from the latest alpine based golang base image
  2. FROM golang:alpine as builder
  3. # Install git
  4. RUN apk update && apk add --no-cache git
  5. # Add maintainer info
  6. LABEL maintainer="Matthias Ladkau <matthias@ladkau.de>"
  7. # Set the current working directory inside the container
  8. WORKDIR /app
  9. # Copy go mod and sum files
  10. COPY go.mod go.sum ./
  11. # Download all dependencies
  12. RUN go mod download
  13. # Copy the source from the current directory to the working directory inside the container
  14. COPY . .
  15. # Build rufs and link statically (no CGO)
  16. # Use ldflags -w -s to omit the symbol table, debug information and the DWARF table
  17. RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags="-w -s" -o rufs ./cli/...
  18. RUN sh ./attach_webzip.sh
  19. # Start again from scratch
  20. FROM scratch
  21. # Copy the rufs binary
  22. COPY --from=builder /app/rufs /rufs
  23. # Set the working directory to data so all created files (e.g. rufs.config.json)
  24. # can be mapped to physical files on disk
  25. WORKDIR /data
  26. # Run eliasdb binary
  27. ENTRYPOINT ["../rufs"]
  28. # To run the server as the current user, expose port 9020 and preserve
  29. # all runtime related files on disk in the local directory run:
  30. #
  31. # docker run --rm --user $(id -u):$(id -g) -v $PWD:/data -p 9020:9020 krotik/rufs server
  32. # To run the client CLI as the current user and use the rufs.secret in the local directory run:
  33. # docker run --rm --network="host" -it -v $PWD:/data --user $(id -u):$(id -g) -v $PWD:/data krotik/rufs client