mirror of https://github.com/VERT-sh/VERT.git
Enhance Dockerfile with build args and healthcheck
Added build arguments and environment variables for configuration. Updated healthcheck command for nginx.
This commit is contained in:
parent
00e38b6e2c
commit
7088a58821
15
Dockerfile
15
Dockerfile
|
|
@ -1,7 +1,10 @@
|
|||
# Use the oven/bun image as the build stage
|
||||
FROM oven/bun AS builder
|
||||
|
||||
# Set working directory inside the container
|
||||
WORKDIR /app
|
||||
|
||||
# Declare build arguments (for environment variables to be passed in during build)
|
||||
ARG PUB_ENV
|
||||
ARG PUB_HOSTNAME
|
||||
ARG PUB_PLAUSIBLE_URL
|
||||
|
|
@ -10,6 +13,7 @@ ARG PUB_DISABLE_ALL_EXTERNAL_REQUESTS
|
|||
ARG PUB_DONATION_URL
|
||||
ARG PUB_STRIPE_KEY
|
||||
|
||||
# Set environment variables inside the container using ARG values
|
||||
ENV PUB_ENV=${PUB_ENV}
|
||||
ENV PUB_HOSTNAME=${PUB_HOSTNAME}
|
||||
ENV PUB_PLAUSIBLE_URL=${PUB_PLAUSIBLE_URL}
|
||||
|
|
@ -18,21 +22,30 @@ ENV PUB_DISABLE_ALL_EXTERNAL_REQUESTS=${PUB_DISABLE_ALL_EXTERNAL_REQUESTS}
|
|||
ENV PUB_DONATION_URL=${PUB_DONATION_URL}
|
||||
ENV PUB_STRIPE_KEY=${PUB_STRIPE_KEY}
|
||||
|
||||
# Copy only package.json to leverage cached layer for dependencies
|
||||
COPY package.json ./
|
||||
|
||||
# Install dependencies using bun package manager
|
||||
RUN bun install
|
||||
|
||||
# Copy the rest of the application files
|
||||
COPY . ./
|
||||
|
||||
# Build the application (usually producing a production-ready bundle)
|
||||
RUN bun run build
|
||||
|
||||
# Use nginx stable alpine image as the final stage for serving static files
|
||||
FROM nginx:stable-alpine
|
||||
|
||||
# Open port 80 for HTTP traffic
|
||||
EXPOSE 80/tcp
|
||||
|
||||
# Copy custom nginx configuration into the container
|
||||
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy the built application from the builder stage to nginx's html directory
|
||||
COPY --from=builder /app/build /usr/share/nginx/html
|
||||
|
||||
# Define a healthcheck to ensure the nginx server is responsive
|
||||
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://localhost || exit 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue