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

51 lines
1.1 KiB
Docker

# Global build argument
ARG THTTPD_VER=2.29
FROM alpine:latest AS builder
# =====BUILD thttpd=====
WORKDIR /usr/src
ARG THTTPD_VER
# Install dependencies & build thttpd
RUN apk update && \
apk add --no-cache curl hugo build-base && \
curl -sSL "https://www.acme.com/software/thttpd/thttpd-$THTTPD_VER.tar.gz" | \
tar xzf - && \
cd "thttpd-$THTTPD_VER" && \
CFLAGS="-O3 -static" ./configure && \
make -j$(nproc)
# =====BUILD THE BLOG=====
WORKDIR /usr/src/app
# Copy site files for building
COPY . ./
# Generate the site
RUN hugo --minify
# ====CREATE RELEASE IMAGE====
FROM alpine:latest
ARG THTTPD_VER
# Install dumb-init & create a non-root user
RUN apk update && \
apk add --no-cache dumb-init
# addgroup -g 82 -S www-data && \
# adduser -u 82 -D -S -G www-data www-data
# Copy over binary & static files
COPY --from=builder /usr/src/thttpd-$THTTPD_VER/thttpd /usr/local/bin/thttpd
COPY --from=builder /usr/src/app/public /var/www/html
COPY thttpd.conf /etc/thttpd.conf
# A static file server doesn't need root
USER 82:82
ENTRYPOINT [ "dumb-init", "--" ]
CMD [ "/usr/local/bin/thttpd", "-D", "-C", "/etc/thttpd.conf" ]