about summary refs log tree commit diff stats
path: root/Dockerfile
diff options
context:
space:
mode:
Diffstat (limited to 'Dockerfile')
-rw-r--r--Dockerfile66
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" ]