diff options
author | Alan Pearce | 2023-09-15 19:35:23 +0200 |
---|---|---|
committer | Alan Pearce | 2023-09-15 19:35:23 +0200 |
commit | 6474b1db0a4f8bdf3c83acd329cf822a9f45f563 (patch) | |
tree | 598a1e3bdc25c4d6f75773925d83a46bbbe19859 /Dockerfile | |
parent | c936c99fad7e090a3caaaa6bdd5fbaf38d39abba (diff) | |
parent | e718339d93e2f60b6df55330aafb2d9536820ce4 (diff) | |
download | website-6474b1db0a4f8bdf3c83acd329cf822a9f45f563.tar.lz website-6474b1db0a4f8bdf3c83acd329cf822a9f45f563.tar.zst website-6474b1db0a4f8bdf3c83acd329cf822a9f45f563.zip |
Merge homestead repository
Diffstat (limited to 'Dockerfile')
-rw-r--r-- | Dockerfile | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/Dockerfile b/Dockerfile index 86b26ea..79533e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,60 @@ -ARG VERSION=2.7.4 -ARG VARIANT=alpine +# syntax = docker/dockerfile:1 -FROM docker.io/caddy:${VERSION}-builder-${VARIANT} AS builder +# Adjust BUN_VERSION as desired +ARG BUN_VERSION=0.8.1 +ARG ZOLA_VERSION=0.17.1 +FROM oven/bun:${BUN_VERSION} as base -RUN xcaddy build \ - --with github.com/gamalan/caddy-tlsredis +LABEL fly_launch_runtime="Bun" -FROM docker.io/caddy:${VERSION}-${VARIANT} +# Bun app lives here +WORKDIR /app -COPY --from=builder /usr/bin/caddy /usr/bin/caddy +# Set production environment +ENV NODE_ENV="production" -COPY Caddyfile /etc/caddy/ -COPY public /srv +# Throw-away build stage to reduce size of final image +FROM base as build -EXPOSE 9091/tcp +# # Install packages needed to build node modules +# RUN apt-get update -qq && \ +# apt-get install -y build-essential pkg-config python-is-python3 -ENV SITE_ROOT=/srv +# Install node modules +COPY --link bun.lockb package.json ./ +RUN bun install --ci -RUN mkdir /etc/caddy/globals/ -RUN touch /etc/caddy/globals/dummy -RUN ["/usr/bin/caddy", "validate", "--config", "/etc/caddy/Caddyfile"] +# Copy application code +COPY --link src src -COPY redis.Caddyfile /etc/caddy/globals/redis +FROM ghcr.io/getzola/zola:v${ZOLA_VERSION} as ssg + +WORKDIR /web + +COPY --link website ./ + +RUN [ "zola", "build", "--force" ] + +FROM alpine:edge as postprocess + +WORKDIR /web + +RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories + +RUN apk add --no-cache prettier@testing make fd brotli gzip zstd + +COPY --from=ssg /web ./ + +RUN make -j4 format compress + +# Final stage for app image +FROM base + +# Copy built application +COPY --from=build /app /app +COPY --from=postprocess /web/ /app/website + +# Start the server by default, this can be overwritten at runtime +EXPOSE 3000 +EXPOSE 9091 +CMD [ "bun", "run", "src/index.ts" ] |