Initial commit: Docker infrastructure for fullstack Vollversammlung app
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
# ---------------
|
||||
# Base: install deps for dev server
|
||||
# ---------------
|
||||
FROM node:20-alpine AS base-dev
|
||||
|
||||
ARG user=viteuser
|
||||
ARG group=node
|
||||
ARG uid=1000
|
||||
ARG gid=1000
|
||||
|
||||
RUN apk add --no-cache \
|
||||
tini \
|
||||
bash
|
||||
|
||||
RUN addgroup -g ${gid} ${group} && \
|
||||
adduser -u ${uid} -G ${group} -s /bin/sh -D ${user}
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm ci || npm install
|
||||
|
||||
# ---------------
|
||||
# Production build stage
|
||||
# ---------------
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ARG VITE_API_URL="http://nginx:80/api"
|
||||
ARG VITE_MERCURE_URL="http://mercure-hub/.well-known/mercure"
|
||||
ARG VITE_OAUTH_AUTHORIZATION_ENDPOINT="https://oauth.vonova.de/oauth/authorize"
|
||||
ARG VITE_OAUTH_TOKEN_ENDPOINT="https://oauth.vonova.de/oauth/token"
|
||||
|
||||
ENV VITE_API_URL=${VITE_API_URL}
|
||||
ENV VITE_MERCURE_URL=${VITE_MERCURE_URL}
|
||||
ENV VITE_OAUTH_AUTHORIZATION_ENDPOINT=${VITE_OAUTH_AUTHORIZATION_ENDPOINT}
|
||||
ENV VITE_OAUTH_TOKEN_ENDPOINT=${VITE_OAUTH_TOKEN_ENDPOINT}
|
||||
|
||||
COPY --from=base-dev /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
RUN npm run build --if-present
|
||||
|
||||
# ---------------
|
||||
# Development stage
|
||||
# ---------------
|
||||
FROM base-dev AS dev
|
||||
|
||||
LABEL maintainer="devops@vollversammlung" \
|
||||
description="Vollversammlung React Vite Dev Image"
|
||||
|
||||
EXPOSE 5173
|
||||
|
||||
CMD ["tini", "--", "npx", "vite", "--host", "0.0.0.0"]
|
||||
|
||||
# ---------------
|
||||
# Production static serve (nginx will be added later)
|
||||
# ---------------
|
||||
FROM nginx:alpine AS production-static
|
||||
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
ARG VITE_API_URL="http://nginx:80/api"
|
||||
RUN printf "server {\n listen 80;\n root /usr/share/nginx/html;\n try_files \$uri \$uri/ /index.html;\n}" > /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
Reference in New Issue
Block a user