diff --git a/.gitignore b/.gitignore index 3b735ec..a8f876d 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ *.so *.dylib +# Environment variables +*.env + # Test binary, built with `go test -c` *.test diff --git a/containers/.env.template b/containers/.env.template new file mode 100644 index 0000000..7b41b9e --- /dev/null +++ b/containers/.env.template @@ -0,0 +1,3 @@ +COURIER_BIND_ADDR=:8842 +COURIER_LOCAL_STORAGE_ENABLED=true +COURIER_LOCAL_STORAGE_PATH=/data/courier \ No newline at end of file diff --git a/containers/build.sh b/containers/build.sh new file mode 100644 index 0000000..5350a46 --- /dev/null +++ b/containers/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build -t trisa/courier:latest -f ./containers/Dockerfile . \ No newline at end of file diff --git a/containers/courier/Dockerfile b/containers/courier/Dockerfile new file mode 100644 index 0000000..f33c381 --- /dev/null +++ b/containers/courier/Dockerfile @@ -0,0 +1,44 @@ +# Dynamic Builds +ARG BUILDER_IMAGE=golang:1.20-buster +ARG FINAL_IMAGE=debian:buster-slim + +# Build Stage +FROM ${BUILDER_IMAGE} AS builder + +ARG GIT_REVISION="" + +# Ensure ca-certificates are up to date +RUN update-ca-certificates + +# Use modeules for dependencies +WORKDIR $GOPATH/src/github.com/trisacrypto/courier +COPY go.mod . +COPY go.sum . + +ENV CGO_ENABLED=0 +ENV GO111MODULE=on +RUN go mod download +RUN go mod verify + +# Copy only what is needed for the build +COPY cmd ./cmd +COPY pkg ./pkg + +# Build the binary +RUN go build -v -o /go/bin/courier -ldflags="-X 'github.com/trisacrypto/courier/pkg.GitVersion=$GIT_REVISION'" ./cmd/courier + +# Final Stage +FROM ${FINAL_IMAGE} AS final + +LABEL maintainer="TRISA " +LABEL description="Certificate Delivery Service" + +# Ensure ca-certificates are up to date +RUN set -x && apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +# Copy the binary to the production image from the builder stage. +COPY --from=builder /go/bin/courier /usr/local/bin/courier + +CMD [ "/usr/local/bin/courier", "serve" ] \ No newline at end of file