forked from krotik/eliasdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
47 lines (33 loc) · 1.42 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Start from the latest alpine based golang base image
FROM golang:alpine as builder
# Install git
RUN apk update && apk add --no-cache git
# Add maintainer info
LABEL maintainer="Matthias Ladkau <[email protected]>"
# Set the current working directory inside the container
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download all dependencies
RUN go mod download
# Copy the source from the current directory to the working directory inside the container
COPY . .
# Build eliasdb and link statically (no CGO)
# Use ldflags -w -s to omit the symbol table, debug information and the DWARF table
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags="-w -s" cli/eliasdb.go
# Start again from scratch
FROM scratch
# Copy the eliasdb binary
COPY --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 disk
WORKDIR /data
# Run eliasdb binary
ENTRYPOINT ["../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