Files
babymonitor/frontend/Dockerfile
T

38 lines
1022 B
Docker

FROM node:22-alpine AS build
ARG VITE_APP_VERSION=unknown
ARG VITE_APP_GITSHA=unknown
ENV VITE_APP_VERSION=$VITE_APP_VERSION
ENV VITE_APP_GITSHA=$VITE_APP_GITSHA
WORKDIR /app
# Copy package files first to leverage Docker cache
COPY package*.json ./
# Install dependencies (including devDependencies for build)
RUN npm install
# Copy the rest of the application source code
COPY . .
# Build the production assets
RUN npm run build
# Stage 2: Production stage
FROM nginx:1.27-alpine
LABEL org.opencontainers.image.source="http://gitea.lan/jacobh2/babymonitor"
LABEL org.opencontainers.image.description="Babymonitor Frontend"
# Copy the built assets from the build stage to Nginx's default HTML directory
COPY --from=build /app/dist /usr/share/nginx/html
# Copy our custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80 to allow access to the web application
EXPOSE 80
# Nginx runs in the foreground by default when using its official image
CMD ["nginx", "-g", "daemon off;"]