46 lines
1.3 KiB
Docker
46 lines
1.3 KiB
Docker
# 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 patch git
|
|
WORKDIR /build
|
|
COPY ./localhost.cnf /build/localhost.cnf
|
|
RUN git clone https://code.rocketnine.space/tslocum/twins.git
|
|
|
|
RUN git config --global user.email "noname@example.com"
|
|
# Apply a needed patches
|
|
COPY ./path-10.patch /build/path-10.patch
|
|
RUN cd /build/twins && git am /build/path-10.patch
|
|
COPY ./activate-images-permanently.patch /build/activate-images-permanently.patch
|
|
RUN cd /build/twins && git am /build/activate-images-permanently.patch
|
|
|
|
RUN cd /build/twins && go build
|
|
|
|
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 /build/twins/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"]
|
|
|