diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..854968e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +** + +!config +!formatter +!*.go +!go.mod +!sample-config.toml +!docker-entrypoint.sh \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..958de83 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM alpine:3.12 AS permissions-giver + +# Make sure docker-entrypoint.sh is executable, regardless of the build host. +WORKDIR /out +COPY docker-entrypoint.sh . +RUN chmod +x docker-entrypoint.sh + +FROM golang:1.14-alpine3.12 AS builder + +# Build wuzz +WORKDIR /out +COPY . . +RUN go build . + +FROM alpine:3.12 AS organizer + +# Prepare executables +WORKDIR /out +COPY --from=builder /out/wuzz . +COPY --from=permissions-giver /out/docker-entrypoint.sh . + +FROM alpine:3.12 AS runner +WORKDIR /wuzz +COPY --from=organizer /out /usr/local/bin +ENTRYPOINT [ "docker-entrypoint.sh" ] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..6a50675 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then + sleep 0.01 + set -- wuzz "$@" +fi + +exec "$@" \ No newline at end of file