ipify/frontend/Dockerfile
2025-12-23 21:27:42 +02:00

36 lines
801 B
Docker

# Build stage
FROM node:18-alpine as build
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy application code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM nginx:alpine
# Copy built files from build stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Create entrypoint script to inject env variables
RUN echo '#!/bin/sh' > /docker-entrypoint.d/40-generate-env.sh && \
echo 'echo "window.ENV = { VITE_API_URL: \"${VITE_API_URL}\" };" > /usr/share/nginx/html/env.js' >> /docker-entrypoint.d/40-generate-env.sh && \
chmod +x /docker-entrypoint.d/40-generate-env.sh
# Expose port
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]