|
# Pulled from https://fossil-scm.org/home/file?name=Dockerfile&ci=trunk |
|
# With more build ARGs, cleaner tarball extraction, HTTPS, etc. |
|
|
|
ARG ALPINE_VERSION |
|
ARG FSLHSH |
|
ARG FSLVER |
|
ARG FSLCFG="" |
|
|
|
# syntax=docker/dockerfile:1.3 |
|
# See www/containers.md for documentation on how to use this file. |
|
|
|
## --------------------------------------------------------------------- |
|
## STAGE 1: Build static Fossil binary |
|
## --------------------------------------------------------------------- |
|
|
|
### We aren't pinning to a more stable version of Alpine because we want |
|
### to build with the latest tools and libraries available in case they |
|
### fixed something that matters to us since the last build. Everything |
|
### below depends on this layer, and so, alas, we toss this container's |
|
### cache on Alpine's release schedule, roughly once a month. |
|
FROM alpine:${ALPINE_VERSION} AS builder |
|
WORKDIR /tmp |
|
|
|
ARG FSLHSH |
|
ARG FSLVER |
|
ARG FSLCFG |
|
|
|
### Bake the basic Alpine Linux into a base layer so it only changes |
|
### when the upstream image is updated or we change the package set. |
|
RUN set -x \ |
|
&& apk update \ |
|
&& apk upgrade --no-cache \ |
|
&& apk add --no-cache \ |
|
gcc make \ |
|
linux-headers musl-dev \ |
|
openssl-dev openssl-libs-static \ |
|
zlib-dev zlib-static curl |
|
|
|
### Build Fossil as a separate layer so we don't have to rebuild the |
|
### Alpine environment for each iteration of Fossil's dev cycle. |
|
ARG FSLDIR="fossil-src-${FSLVER}" |
|
ARG FSLSTB="${FSLDIR}.tar.gz" |
|
ARG FSLURL="https://fossil-scm.org/home/tarball/${FSLHSH}/${FSLSTB}" |
|
RUN curl -o $FSLSTB $FSLURL |
|
RUN tar -xzf $FSLSTB |
|
RUN mv $FSLDIR src |
|
RUN m=src/src/main.mk && src/configure --static CFLAGS='-Os -s' $FSLCFG && make -j11 |
|
|
|
## --------------------------------------------------------------------- |
|
## STAGE 2: Pare that back to the bare essentials. |
|
## --------------------------------------------------------------------- |
|
|
|
FROM busybox AS os |
|
ARG UID=499 |
|
|
|
### Set up that base OS for our specific use without tying it to |
|
### anything likely to change often. So long as the user leaves |
|
### UID alone, this layer will be durable. |
|
RUN set -x \ |
|
&& mkdir log museum \ |
|
&& echo "root:x:0:0:Admin:/:/false" > /tmp/passwd \ |
|
&& echo "root:x:0:root" > /tmp/group \ |
|
&& echo "fossil:x:${UID}:${UID}:User:/museum:/false" >> /tmp/passwd \ |
|
&& echo "fossil:x:${UID}:fossil" >> /tmp/group |
|
|
|
|
|
## --------------------------------------------------------------------- |
|
## STAGE 3: Drop BusyBox, too, now that we're done with its /bin/sh &c |
|
## --------------------------------------------------------------------- |
|
|
|
FROM scratch AS run |
|
COPY --from=os /tmp/group /tmp/passwd /etc/ |
|
COPY --from=os --chown=fossil:fossil /log /log/ |
|
COPY --from=os --chown=fossil:fossil /museum /museum/ |
|
COPY --from=os --chmod=1777 /tmp /tmp/ |
|
COPY --from=builder /tmp/fossil /bin/ |
|
|
|
|
|
## --------------------------------------------------------------------- |
|
## RUN! |
|
## --------------------------------------------------------------------- |
|
|
|
ENV PATH "/bin" |
|
EXPOSE 8080/tcp |
|
USER fossil |
|
ENTRYPOINT [ "fossil", "server", "museum/repo.fossil" ] |
|
CMD [ \ |
|
"--create", \ |
|
"--https", \ |
|
"--jsmode", "bundled", \ |
|
"--user", "admin" ] |
Thank you for this kickstart! I was able to get it working with less settings (which may or not be a good thing).
Initialized and published with:
Then replace the empty default repo with your own using
fly sftp shell ...
(orfly ssh console -C fossil new ...
)Expanded details of the recipe at https://flyio-fossil.fly.dev/flyio/file?name=Readme.md&ci=tip (I don't know how long I'll keep the demo going. So far it's free though so it will be some while anyway.)