~priegger/go-hello-world

9f2a8a7f42190de5a078b1bd4232f3ba9a70bdf7 — Philipp Riegger 2 years ago 174829b master
add docker build
3 files changed, 36 insertions(+), 0 deletions(-)

A Dockerfile
A README.md
A go.sum
A Dockerfile => Dockerfile +19 -0
@@ 0,0 1,19 @@
FROM golang:1.18-alpine as builder

WORKDIR /app

COPY go.mod ./
COPY go.sum ./

RUN go mod download

COPY *.go ./

RUN CGO_ENABLED=0 go build -o ./go-hello-world 


FROM scratch

COPY --from=builder /app/go-hello-world /bin/go-hello-world

ENTRYPOINT [ "/bin/go-hello-world" ]

A README.md => README.md +17 -0
@@ 0,0 1,17 @@
# go-hello-world

A simple hello-world go application.

## Building and running the docker image

### Using nix

    docker load < $(nix-build ci.nix -A docker-image)
    docker run --rm -it --name go-hello-world-nix go-hello-world:dev-nix
    docker export go-hello-world-nix | tar tf -

### Using the Dockerfile

    docker build -t go-hello-world:dev-alpine .
    docker run --rm -it -p 8000 --name go-hello-world-alpine go-hello-world:dev-alpine
    docker export go-hello-world-alpine | tar tf -

A go.sum => go.sum +0 -0