mirror of https://github.com/VERT-sh/VERT.git
Refactor Dockerfile for build and healthcheck
Updated Dockerfile to improve build process and healthcheck.
This commit is contained in:
parent
00e38b6e2c
commit
41037359c3
46
Dockerfile
46
Dockerfile
|
|
@ -1,38 +1,62 @@
|
||||||
|
# Stage 1: Build the application using the bun container
|
||||||
FROM oven/bun AS builder
|
FROM oven/bun AS builder
|
||||||
|
|
||||||
|
# Set the working directory inside the container
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Build-time arguments (do NOT include secrets here)
|
||||||
ARG PUB_ENV
|
ARG PUB_ENV
|
||||||
ARG PUB_HOSTNAME
|
ARG PUB_HOSTNAME
|
||||||
ARG PUB_PLAUSIBLE_URL
|
ARG PUB_PLAUSIBLE_URL
|
||||||
ARG PUB_VERTD_URL
|
|
||||||
ARG PUB_DISABLE_ALL_EXTERNAL_REQUESTS
|
ARG PUB_DISABLE_ALL_EXTERNAL_REQUESTS
|
||||||
ARG PUB_DONATION_URL
|
ARG PUB_DONATION_URL
|
||||||
ARG PUB_STRIPE_KEY
|
ARG PUB_STRIPE_KEY
|
||||||
|
|
||||||
ENV PUB_ENV=${PUB_ENV}
|
# Expose ARGs as environment variables during build
|
||||||
ENV PUB_HOSTNAME=${PUB_HOSTNAME}
|
ENV PUB_ENV=${PUB_ENV} \
|
||||||
ENV PUB_PLAUSIBLE_URL=${PUB_PLAUSIBLE_URL}
|
PUB_HOSTNAME=${PUB_HOSTNAME} \
|
||||||
ENV PUB_VERTD_URL=${PUB_VERTD_URL}
|
PUB_PLAUSIBLE_URL=${PUB_PLAUSIBLE_URL} \
|
||||||
ENV PUB_DISABLE_ALL_EXTERNAL_REQUESTS=${PUB_DISABLE_ALL_EXTERNAL_REQUESTS}
|
PUB_DISABLE_ALL_EXTERNAL_REQUESTS=${PUB_DISABLE_ALL_EXTERNAL_REQUESTS} \
|
||||||
ENV PUB_DONATION_URL=${PUB_DONATION_URL}
|
PUB_DONATION_URL=${PUB_DONATION_URL} \
|
||||||
ENV PUB_STRIPE_KEY=${PUB_STRIPE_KEY}
|
PUB_STRIPE_KEY=${PUB_STRIPE_KEY}
|
||||||
|
|
||||||
COPY package.json ./
|
# Copy dependency manifest files first (for efficient caching)
|
||||||
|
COPY package.json ./ # Node dependencies manifest
|
||||||
|
COPY bun.lockb ./ # Bun lockfile
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
RUN bun install
|
RUN bun install
|
||||||
|
|
||||||
COPY . ./
|
# Copy source files
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
# Run build script to create production assets
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
|
# Stage 2: Serve static files with Nginx
|
||||||
FROM nginx:stable-alpine
|
FROM nginx:stable-alpine
|
||||||
|
|
||||||
|
# Add labels for source and maintainer info
|
||||||
|
LABEL org.opencontainers.image.source="https://github.com/VERT-sh/VERT" \
|
||||||
|
maintainer="VERT-sh"
|
||||||
|
|
||||||
|
# Expose port 80
|
||||||
EXPOSE 80/tcp
|
EXPOSE 80/tcp
|
||||||
|
|
||||||
|
# Install curl for healthcheck
|
||||||
|
RUN apk add --no-cache curl
|
||||||
|
|
||||||
|
# Copy custom nginx configuration if exists
|
||||||
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
|
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# Copy build output from previous stage to nginx's serving directory
|
||||||
COPY --from=builder /app/build /usr/share/nginx/html
|
COPY --from=builder /app/build /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Change ownership to nginx user for proper permission handling
|
||||||
|
RUN chown -R nginx:nginx /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Define a simple HTTP healthcheck
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
CMD curl --fail --silent --output /dev/null http://localhost || exit 1
|
CMD curl --fail --silent --output /dev/null http://127.0.0.1/ || exit 1
|
||||||
|
|
||||||
|
# Use nginx's default command to start serving
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue