| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | # Start from the latest alpine based golang base imageFROM golang:alpine as builder# Install gitRUN apk update && apk add --no-cache git# Add maintainer infoLABEL maintainer="Matthias Ladkau <matthias@ladkau.de>"# Set the current working directory inside the containerWORKDIR /app# Copy go mod and sum filesCOPY go.mod go.sum ./# Download all dependenciesRUN go mod download# Copy the source from the current directory to the working directory inside the containerCOPY . .# Build eliasdb and link statically (no CGO)# Use ldflags -w -s to omit the symbol table, debug information and the DWARF tableRUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags="-w -s" cli/eliasdb.go# Start again from scratchFROM scratch# Copy the eliasdb binaryCOPY --from=builder /app/eliasdb /eliasdb# Set the working directory to data so all created files (e.g. eliasdb.config.json)# can be mapped to physical files on diskWORKDIR /data# Run eliasdb binaryENTRYPOINT ["../eliasdb"]# To run the server as the current user, expose port 9090 and preserve # all runtime related files on disk in the local directory run:## docker run --rm --user $(id -u):$(id -g) -v $PWD:/data -p 9090:9090 krotik/eliasdb server# To run the console as the current user and use the eliasdb.config.json in # the local directory run:# docker run --rm --network="host" -it -v $PWD:/data --user $(id -u):$(id -g) -v $PWD:/data krotik/eliasdb console
 |