Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile #4

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*.so
*.dylib

# Environment variables
*.env

# Test binary, built with `go test -c`
*.test

Expand Down
3 changes: 3 additions & 0 deletions containers/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COURIER_BIND_ADDR=:8842
COURIER_LOCAL_STORAGE_ENABLED=true
COURIER_LOCAL_STORAGE_PATH=/data/courier
3 changes: 3 additions & 0 deletions containers/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker build -t trisa/courier:latest -f ./containers/Dockerfile .
44 changes: 44 additions & 0 deletions containers/courier/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <info@trisa.io>"
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" ]