ibannieto's capsule

Running molly-brown in a container

I just want to try to run my capsule in a single container.

In order to do that, I just need a gemini server (I choose molly-brown), docker and my content (that's my *.gmi files).

molly-brown is a gemini server written in golang

Project Structure

This should be easy, you must create two files, then copy your gemini content to a directory and finally build the container:

- Dockerfile

- molly.conf

- certificate files (optional)

- content/ directory with your *.gmi files

The Dockerfile

This is the Dockerfile. You should update the 'subj' parameters in order to match your requirements:

FROM golang:1.19.3-alpine as build
RUN apk add -U --no-cache ca-certificates git upx openssl
RUN go install tildegit.org/solderpunk/molly-brown@latest
RUN openssl req \
      -newkey rsa:4096 \
      -x509 \
      -sha256 \
      -days 365 \
      -subj '/C=UK/ST=Scotland/L=Edinburgh/O=ibannieto.info/CN=localhost' \
      -nodes \
      -out molly.crt \
      -keyout molly.key

FROM alpine:3.11

RUN addgroup --system molly && \
    adduser  --system molly

RUN mkdir /opt/molly && \
    chown molly:molly /opt/molly

COPY --from=build --chown=molly:molly /go/bin/molly-brown /opt/molly/molly-brown
COPY --from=build --chown=molly:molly /go/molly.crt       /opt/molly/molly.crt
COPY --from=build --chown=molly:molly /go/molly.key       /opt/molly/molly.key

COPY --chown=molly:molly molly.conf /opt/molly/molly.conf

RUN mkdir -p /var/gemini/cgi-bin && \
    chown -R molly:molly /var/gemini

RUN ln -s /opt/molly/molly.conf /etc/molly.conf

COPY content/ /var/gemini
RUN chown -R molly:molly /var/gemini

EXPOSE 1965

USER molly

ENTRYPOINT /opt/molly/molly-brown

Original Dockerfile

Gemini server configuration

This is the configuration file 'molly.conf':

Port = 1965
Hostname = "localhost"
CertPath = "/opt/molly/molly.crt"
KeyPath = "/opt/molly/molly.key"
DocBase = "/var/gemini/"
#HomeDocBase = "users"
GeminiExt = "gmi"
DefaultLang = "en"
AccessLog = "/opt/molly/access.log"
ErrorLog = "/opt/molly/error.log"
#ReadMollyFiles = true
#DirectorySort = "Time"
#DirectoryReverse = true
#DirectoryTitles = true
CGIPaths = ["/var/gemini/cgi-bin"]
[MimeOverrides]
"atom.xml$" = "application/atom+xml"
"rss.xml$" = "application/rss+xml"

Build the container

Using docker:

docker build -t molly-brown:latest .

Running the container:

docker run --rm -p 1965:1965 molly-brown:latest

After this, you can browse your gemini client using gemini://localhost/index.gmi

Back