52 lines
1.3 KiB
Docker
52 lines
1.3 KiB
Docker
# ==================================================
|
|
# Build Swift Image
|
|
# ==================================================
|
|
FROM swift:6.0-noble AS build
|
|
|
|
# Install OS updates
|
|
RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \
|
|
&& apt-get -q update \
|
|
&& apt-get -q dist-upgrade -y
|
|
|
|
WORKDIR /build
|
|
# First just resolve dependencies.
|
|
COPY ./Package.* ./
|
|
RUN --mount=type=cache,target=/build/.build swift package resolve
|
|
|
|
# Copy entire repo into container
|
|
COPY . .
|
|
|
|
# Build the static site.
|
|
RUN --mount=type=cache,target=/build/.build swift run
|
|
|
|
# ==================================================
|
|
# Build CSS Image
|
|
# ==================================================
|
|
|
|
FROM node:23-alpine AS css
|
|
|
|
WORKDIR /build
|
|
|
|
RUN npm install -g pnpm@latest-10
|
|
|
|
COPY . .
|
|
COPY --from=build /build/deploy ./deploy
|
|
|
|
RUN pnpm install && pnpm run css-build
|
|
RUN npx -y pagefind --site deploy
|
|
|
|
# ==================================================
|
|
# Run Image
|
|
# ==================================================
|
|
FROM caddy:2.9.1-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=css /build/deploy .
|
|
COPY --from=css /build/content/static/output.css ./static/output.css
|
|
COPY --from=css /build/deploy/pagefind ./pagefind
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["/usr/bin/caddy", "file-server", "--root", "/app", "--listen", ":80"]
|