From 5e7afe5f59a4a5d7a56d0ea2de6867b1911d53ff Mon Sep 17 00:00:00 2001 From: Robbie Page Date: Thu, 21 Feb 2019 14:14:50 -0500 Subject: [PATCH] Add a build and run Dockerfile (#6) --- Dockerfile | 28 ++++++++++++++++++++++++++++ README.md | 18 +++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ab8049e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# build +FROM golang:1.11.5-stretch AS build-env + +WORKDIR /src + +ADD . . + +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o app . + +# run +FROM alpine + +RUN apk add --no-cache \ + ca-certificates + +RUN addgroup -S app \ + && adduser -S -g app app + +WORKDIR /home/app + +COPY --from=build-env /src/app . + +RUN chown -R app:app ./ + +USER app +ENV USER=app + +ENTRYPOINT ["./app"] diff --git a/README.md b/README.md index 290ef6f..4ab827c 100644 --- a/README.md +++ b/README.md @@ -135,10 +135,26 @@ Gotify-CLI will search the following paths for a config file: "token": "A4ZudDRdLT40L5X", "url": "https://gotify.example.com" } +``` + +### Dockerfile +The Dockerfile contains the steps necessary to build a new version of the CLI and then run it in +a minimal Alpine container. + +**Build:** + +```bash +docker build -t gotify/gotify-cli . +``` + +**Run (this assumes your `cli.json` file is in the current working directory):** + +```bash +docker run -it -v "$PWD/cli.json:/home/app/cli.json" gotify/gotify-cli:latest push -p 5 "Test from Gotify CLI" ``` [gotify/server]: https://github.com/gotify/server [travis-badge]: https://travis-ci.org/gotify/cli.svg?branch=master [travis]: https://travis-ci.org/gotify/cli [badge-release]: https://img.shields.io/github/release/gotify/cli.svg - [release]: https://github.com/gotify/cli/releases/latest \ No newline at end of file + [release]: https://github.com/gotify/cli/releases/latest