2021-07-19 18:43:55 +02:00
|
|
|
# Global build argument
|
|
|
|
ARG THTTPD_VER=2.29
|
|
|
|
|
2021-07-08 22:38:03 +02:00
|
|
|
FROM alpine:latest AS builder
|
|
|
|
|
|
|
|
|
2021-07-19 18:43:55 +02:00
|
|
|
# =====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" && \
|
|
|
|
./configure && \
|
|
|
|
make
|
|
|
|
|
|
|
|
|
|
|
|
# =====BUILD THE BLOG=====
|
|
|
|
WORKDIR /usr/src/app
|
2021-07-08 22:38:03 +02:00
|
|
|
|
|
|
|
# Copy site files for building
|
|
|
|
COPY . ./
|
|
|
|
|
|
|
|
# Generate the site
|
|
|
|
RUN hugo --minify
|
|
|
|
|
|
|
|
|
2021-07-19 18:43:55 +02:00
|
|
|
# ====CREATE RELEASE IMAGE====
|
|
|
|
FROM alpine:latest
|
|
|
|
ARG THTTPD_VER
|
|
|
|
|
2021-07-19 19:00:07 +02:00
|
|
|
# Install dumb-init & create a non-root user
|
2021-07-19 18:43:55 +02:00
|
|
|
RUN apk update && \
|
2021-07-19 19:00:07 +02:00
|
|
|
apk add --no-cache dumb-init && \
|
|
|
|
addgroup -g 82 -S www-data && \
|
|
|
|
adduser -u 82 -D -S -G www-data www-data
|
2021-07-19 18:43:55 +02:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2021-07-19 19:00:07 +02:00
|
|
|
# A static file server doesn't need root
|
|
|
|
USER www-data:www-data
|
2021-07-08 22:38:03 +02:00
|
|
|
|
2021-07-19 18:43:55 +02:00
|
|
|
ENTRYPOINT [ "dumb-init", "--" ]
|
|
|
|
CMD [ "/usr/local/bin/thttpd", "-D", "-C", "/etc/thttpd.conf" ]
|