This repository has been archived on 2021-08-14. You can view files and clone it, but cannot push or open issues/pull-requests.
bever-dam/Dockerfile

62 lines
1.4 KiB
Docker

# Global build argument
ARG THTTPD_VER=2.29
ARG DI_VER=1.2.5
FROM ubuntu:latest AS builder
# =====BUILD BINARIES=====
WORKDIR /usr/src
ARG THTTPD_VER
ARG DI_VER
# Install dependencies & build thttpd
RUN apt update && \
apt install -y --no-install-recommends \
curl \
ca-certificates \
hugo \
musl-dev \
musl-tools \
build-essential && \
curl -sSL "https://www.acme.com/software/thttpd/thttpd-$THTTPD_VER.tar.gz" | \
tar xzf - && \
cd "thttpd-$THTTPD_VER" && \
CC="musl-gcc -static" ./configure && \
make -j$(nproc)
# Build dumb-init
RUN curl -sSL "https://github.com/Yelp/dumb-init/archive/refs/tags/v$DI_VER.tar.gz" | \
tar xzf - && \
cd "dumb-init-$DI_VER" && \
CC="musl-gcc -static" make build
# =====BUILD BLOG=====
WORKDIR /usr/src/app
# Copy site files for building
COPY . ./
# Generate the site
RUN hugo --minify && \
find public -type f -exec chmod 644 {} \;
# ====CREATE RELEASE IMAGE====
FROM scratch
ARG THTTPD_VER
ARG DI_VER
# Copy over binary & static files
COPY --from=builder /usr/src/thttpd-$THTTPD_VER/thttpd /bin/thttpd
COPY --from=builder /usr/src/dumb-init-$DI_VER/dumb-init /bin/dumb-init
COPY --from=builder /usr/src/app/public /static
COPY thttpd.conf /etc/thttpd.conf
# A static file server doesn't need root
USER 82:82
ENTRYPOINT [ "/bin/dumb-init", "--" ]
CMD [ "/bin/thttpd", "-D", "-C", "/etc/thttpd.conf" ]