dockerize go app

This commit is contained in:
Travis Shears 2025-09-25 13:36:01 +02:00
parent 4084f8dad7
commit 6d859012ce
4 changed files with 53 additions and 0 deletions

28
Dockerfile Normal file
View file

@ -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"]

View file

@ -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:

16
build.sh Executable file
View file

@ -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"

View file

@ -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")