Docker Image Builds
This commit is contained in:
+16
-2
@@ -1,5 +1,7 @@
|
||||
# Build Frontend
|
||||
FROM oven/bun:alpine AS frontend-builder
|
||||
# Frontend output is static, arch-independent assets, so build it natively on the
|
||||
# build host (no emulation) regardless of the target platform.
|
||||
FROM --platform=$BUILDPLATFORM oven/bun:alpine AS frontend-builder
|
||||
WORKDIR /app
|
||||
COPY package.json ./
|
||||
RUN bun install
|
||||
@@ -7,6 +9,7 @@ COPY . .
|
||||
RUN bun run build
|
||||
|
||||
# Build Backend
|
||||
# Built for the target platform (under QEMU emulation for non-native arches).
|
||||
FROM rust:alpine AS backend-builder
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache musl-dev openssl-dev openssl-libs-static pkgconfig git
|
||||
@@ -19,10 +22,21 @@ RUN cargo build --release
|
||||
|
||||
# Final Runtime Image
|
||||
FROM alpine:3.19
|
||||
# Provided automatically by buildx (e.g. "amd64", "arm64").
|
||||
ARG TARGETARCH
|
||||
WORKDIR /app
|
||||
RUN apk add --no-cache libgcc openssl pandoc curl sqlite
|
||||
RUN mkdir -p /data
|
||||
RUN curl -L https://github.com/Myriad-Dreamin/tinymist/releases/latest/download/tinymist-alpine-x64 -o /usr/local/bin/tinymist && chmod +x /usr/local/bin/tinymist
|
||||
# Install tinymist for the target architecture.
|
||||
RUN case "$TARGETARCH" in \
|
||||
amd64) TINYMIST_TRIPLE="x86_64-unknown-linux-musl" ;; \
|
||||
arm64) TINYMIST_TRIPLE="aarch64-unknown-linux-musl" ;; \
|
||||
*) echo "Unsupported TARGETARCH: $TARGETARCH" && exit 1 ;; \
|
||||
esac && \
|
||||
curl -fL "https://github.com/Myriad-Dreamin/tinymist/releases/latest/download/tinymist-${TINYMIST_TRIPLE}.tar.gz" -o /tmp/tinymist.tar.gz && \
|
||||
tar -xzf /tmp/tinymist.tar.gz -C /usr/local/bin --strip-components=1 "tinymist-${TINYMIST_TRIPLE}/tinymist" && \
|
||||
chmod +x /usr/local/bin/tinymist && \
|
||||
rm /tmp/tinymist.tar.gz
|
||||
COPY --from=frontend-builder /app/build /app/build
|
||||
COPY --from=backend-builder /app/server/target/release/server /app/server
|
||||
|
||||
|
||||
Reference in New Issue
Block a user