From 6d859012ce0dac7b76470f8bb4dded237dcf4705 Mon Sep 17 00:00:00 2001 From: Travis Shears Date: Thu, 25 Sep 2025 13:36:01 +0200 Subject: [PATCH] dockerize go app --- Dockerfile | 28 ++++++++++++++++++++++++++++ README.md | 8 ++++++++ build.sh | 16 ++++++++++++++++ main.go | 1 + 4 files changed, 53 insertions(+) create mode 100644 Dockerfile create mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..afb51df --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +# Build stage +FROM golang:1.25-alpine AS builder + +WORKDIR /app + +# Install git if needed for go mod +RUN apk add --no-cache git + +# Copy go mod and sum files +COPY go.mod go.sum ./ + +# Download dependencies +RUN go mod download + +COPY main.go . + +RUN go build -o main . + +FROM alpine:latest + +WORKDIR /app + +COPY --from=builder /app/main . +COPY keys ./keys + +EXPOSE 8080 + +CMD ["./main", "-cert=./keys/cert.crt.pem", "-key=./keys/localhost_key.pem", "-host=0.0.0.0:8080"] diff --git a/README.md b/README.md index e98615b..f7f7ca9 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,14 @@ My own little corner of Geminispace. A partner site to my personal website https - https://geminiprotocol.net/software/ - https://geminiprotocol.net/ +## Deployment + +Goal is selfhost my capsule site on my nomad homelab. + + + +https://jonathanmh.com/p/mirroring-next-blog-to-gemini/ + ## Dev Generate self-signed certificate: diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..079eef2 --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +export AWS_PROFILE=personal +export AWS_REGION=eu-central-1 + +REPO_NAME="gemini-capsule-homelabstack" + +if ! aws ecr describe-repositories --repository-names "$REPO_NAME" >/dev/null 2>&1; then + aws ecr create-repository --repository-name "$REPO_NAME" +fi + +docker buildx build --platform linux/amd64,linux/arm64 -t 853019563312.dkr.ecr.eu-central-1.amazonaws.com/gemini-capsule-homelabstack:latest --push . + +echo "Docker image built and pushed to AWS ECR" diff --git a/main.go b/main.go index f2e1eb1..857d8e0 100644 --- a/main.go +++ b/main.go @@ -75,6 +75,7 @@ func userName(r *gemini.Request) []string { } func main() { + println("Starting gemini server") var host, cert, key string flag.StringVar(&host, "host", ":1965", "listen on host and port. Example: hostname:1965") flag.StringVar(&cert, "cert", "server.crt.pem", "certificate file")