aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2018-08-07 14:38:40 +0100
committerNiall Sheridan <nsheridan@gmail.com>2018-08-07 14:54:48 +0100
commitb7b3e5cfad53732a379b3784ec2c3b72577ab665 (patch)
treec46d7ea1c2bcd8c5791a677e3c0c901251c60736
parent446206904ecf600375d3022419d9b73f1c3bdbfa (diff)
Use multi-stage build with current Go version
-rw-r--r--Dockerfile17
-rw-r--r--README.md7
2 files changed, 17 insertions, 7 deletions
diff --git a/Dockerfile b/Dockerfile
index 8416bbe..273c1be 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,9 +1,12 @@
-FROM golang:1.7-alpine
+FROM golang:latest as build
+LABEL maintainer="nsheridan@gmail.com"
+ARG SRC_DIR=/go/src/github.com/nsheridan/cashier
+WORKDIR ${SRC_DIR}
+ADD . ${SRC_DIR}
+RUN CGO_ENABLED=0 GOOS=linux go install -a -installsuffix static ./cmd/cashierd
-ADD . /go/src/github.com/nsheridan/cashier
-RUN apk add --update build-base
-RUN go install github.com/nsheridan/cashier/cmd/cashierd
-
-VOLUME /cashier
+FROM scratch
+LABEL maintainer="nsheridan@gmail.com"
WORKDIR /cashier
-ENTRYPOINT /go/bin/cashierd
+COPY --from=build /go/bin/cashierd /
+ENTRYPOINT ["/cashierd"]
diff --git a/README.md b/README.md
index 4dd208c..b1ddfbb 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,7 @@
- [Cashier](#cashier)
- [How it works](#how-it-works)
- [Installing](#installing)
+ - [Docker](#docker)
- [Requirements](#requirements)
- [Server](#server)
- [Client](#client)
@@ -67,6 +68,12 @@ The server requires a configuration file ([sample config](example-server.conf)).
See [the configuration section](#configuration) for more detail.
+## Docker
+A [docker image is available](https://hub.docker.com/r/nsheridan/cashier). Example usage:
+```
+docker run -it --rm -p 10000:10000 --name cashier -v ${PWD}:/cashier nsheridan/cashier
+```
+
# Requirements
## Server
Go 1.10 or later, though it may work with earlier versions.