From 7ab20def7a63c4245ca073b0a46533683f246145 Mon Sep 17 00:00:00 2001 From: Ramon Quitales Date: Sat, 21 Mar 2020 16:55:51 -0700 Subject: [PATCH] Add Dockerfile for example CLI --- Dockerfile | 14 ++++++++++++++ README.md | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7e904b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +# Copyright (c) 2020 Ramon Quitales +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +FROM golang:1.14.1-alpine AS builder +WORKDIR /go/memdb/ +COPY . /go/memdb/ +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o go-memdb . + +FROM alpine:latest +WORKDIR /memdb/ +COPY --from=builder /go/memdb/go-memdb /memdb/go-memdb +CMD ["./go-memdb"] \ No newline at end of file diff --git a/README.md b/README.md index 6aabd38..96720f5 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ db := memdb.NewDB() Please refer to the [GoDoc](https://pkg.go.dev/github.com/rquitales/go-memdb) page full documentation. A example CLI implementation of `memdb` can also be seen in the [main.go](main.go) file. ### Running The Example CLI +#### From Source 1. Download the appropriate binary from your target OS from the [releases page](https://github.com/rquitales/go-memdb/releases), or compile from source with `go build -v .` after cloning this repository. 2. Start the executable, eg: `./go-memdb` 3. Type your commands (into STDIN) @@ -65,6 +66,15 @@ Please refer to the [GoDoc](https://pkg.go.dev/github.com/rquitales/go-memdb) pa The query/functions are case insensitive, but the key/values are case sensitive! +#### With Docker +1. Build the docker image from the given Dockerfile in this project: + ``` + docker build -t go-memdb . + ``` +2. Run the built image in a container interactively: + ``` + docker run -it --rm go-memdb + ```