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 eliasdb 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" cli/eliasdb.go
  18. # Start again from scratch
  19. FROM scratch
  20. # Copy the eliasdb binary
  21. COPY --from=builder /app/eliasdb /eliasdb
  22. # Set the working directory to data so all created files (e.g. eliasdb.config.json)
  23. # can be mapped to physical files on disk
  24. WORKDIR /data
  25. # Run eliasdb binary
  26. ENTRYPOINT ["../eliasdb"]
  27. # To run the server as the current user, expose port 9090 and preserve
  28. # all runtime related files on disk in the local directory run:
  29. #
  30. # docker run --rm --user $(id -u):$(id -g) -v $PWD:/data -p 9090:9090 krotik/eliasdb server
  31. # To run the console as the current user and use the eliasdb.config.json in
  32. # the local directory run:
  33. # docker run --rm --network="host" -it -v $PWD:/data --user $(id -u):$(id -g) -v $PWD:/data krotik/eliasdb console