From 856d524707842330998f3de29fd862c4c0fda2da Mon Sep 17 00:00:00 2001 From: Aaron Fischer Date: Thu, 6 May 2021 20:56:34 +0200 Subject: [PATCH] Initial insert --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ docker-compose.yml | 7 +++++++ localhost.cnf | 11 +++++++++++ twins.ini | 15 +++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 localhost.cnf create mode 100644 twins.ini diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d618265 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Twins, a simple gemini server and reverse proxy +# @Author Twins: Trevor Slocum +# @Author Docker build: Aaron Fischer + +# Build +FROM golang:1.16-alpine AS builder +RUN apk add --no-cache openssl +RUN go get -v code.rocketnine.space/tslocum/twins +COPY ./localhost.cnf /build/localhost.cnf +RUN openssl req \ + -x509 \ + -out /build/localhost.crt \ + -keyout /build/localhost.key \ + -newkey rsa:2048 \ + -nodes \ + -sha256 \ + -subj '/CN=localhost' \ + -extensions EXT \ + -config /build/localhost.cnf + +# Compress +FROM gruebel/upx:latest as upx +COPY --from=builder /go/bin/twins /app.org +RUN upx --best --lzma -o /app /app.org + +# Final image +FROM alpine:3.13 +WORKDIR /app +COPY --from=upx /app /app/twins +COPY ./twins.ini /app/config/twins.ini +COPY --from=builder /build/localhost.crt /app/certs/localhost.crt +COPY --from=builder /build/localhost.key /app/certs/localhost.key +EXPOSE 1965 +CMD ["/app/twins", "-config", "/app/config/twins.ini"] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cfdaf57 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: "3" + +services: + twins: + build: . + ports: + - 1965:1965 diff --git a/localhost.cnf b/localhost.cnf new file mode 100644 index 0000000..d30992c --- /dev/null +++ b/localhost.cnf @@ -0,0 +1,11 @@ +[dn] +CN=localhost + +[req] +distinguished_name = dn + +[EXT] +subjectAltName=DNS:localhost +keyUsage=digitalSignature +extendedKeyUsage=serverAuth + diff --git a/twins.ini b/twins.ini new file mode 100644 index 0000000..50b823b --- /dev/null +++ b/twins.ini @@ -0,0 +1,15 @@ +listen: :1965 +disablehttps: true +disablesize: true + +hosts: + default: + paths: + - lang: en + symlinks: false + localhost: + cert: /app/certs/localhost.crt + key: /app/certs/localhost.key + paths: + - path: / + command: echo "Welcome to twins"