Dockerfile for agate
- Tuesday, February 9, 2021
Background
My domain runs on a Linode server. To try to make my life a little easier, I've standardized on running all my services in Docker containers (whether this actually makes my life easier or not is up for debate). Since I wanted to run an agate server, too, I decided to put together a little Docker container to help me.
Generating Certificates
You'll need to generate your own key and cert, and keep them in the same file as the Dockerfile when you build your container. The quickest way is to do:
openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
-days 3650 -nodes -subj "/CN=example.com"
Just replace example.com with the correct domain name!
Building the Container
Stick the key.rsa, cert.pem, and Dockerfile into the same directory, and then build with:
docker build --rm --tag agate:latest .
Running the Container
To run this, you'd do something like:
docker run -d -v /your/gemini/files:/var/gemini -p 1965:1965 --rm agate:latest
Here, /your/gemini/files is where you store your actual content.
The Dockerfile
FROM alpine:3.13
RUN apk update
RUN apk add --no-cache openssl-dev curl git build-base openssl-dev
RUN mkdir -p /etc/agate
COPY key.rsa /etc/agate/key.rsa
COPY cert.pem /etc/agate/cert.pem
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN git clone https://github.com/mbrubeck/agate.git /tmp/agate
RUN mkdir /var/gemini
RUN source ${HOME}/.cargo/env && \
cd /tmp/agate/ && \
cargo build --release && \
mv /tmp/agate/target/release/agate /usr/local/bin/agate
EXPOSE 1965/tcp
VOLUME ["/var/gemini"]
RUN rm -rf /tmp/agate ${HOME}/.cargo
ENTRYPOINT exec /usr/local/bin/agate --content /var/gemini \
--key /etc/agate/key.rsa --cert /etc/agate/cert.pem \
--log-ip --lang en-US