Dockerfile upd drone-config
Some checks reported errors
continuous-integration/drone Build encountered an error

This commit is contained in:
Urban Modig
2025-10-09 15:02:36 +02:00
parent 48214a305a
commit 1b74650aa2
3 changed files with 133 additions and 0 deletions

65
Dockerfile Normal file
View File

@ -0,0 +1,65 @@
# syntax=docker/dockerfile:1.7
############################
# Build stage
############################
FROM node:20-alpine AS build
WORKDIR /app
# pnpm via Corepack
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack prepare pnpm@9.12.0 --activate
# Installera beroenden
COPY package.json pnpm-lock.yaml* ./
RUN pnpm install --frozen-lockfile
# App-källor
COPY . .
# --- Build args (styr Vite) ---
# Backend-url (ex sätts i Drone secrets)
ARG VITE_API_BASE_URL=http://localhost:8080
# Base path för proxy under /hemhub/
ARG VITE_BASE_PATH=/
ENV VITE_API_BASE_URL=${VITE_API_BASE_URL}
ENV VITE_BASE_PATH=${VITE_BASE_PATH}
# Bygg (Vite läser env vid build)
RUN pnpm build
############################
# Runtime stage (Nginx)
############################
FROM nginx:1.27-alpine AS runtime
# Minimal nginx-konfig med SPA-fallback
RUN <<'NGINX' sh -lc 'cat >/etc/nginx/conf.d/default.conf'
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# gzip statiska assets
gzip on;
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
# Single Page App fallback
location / {
try_files $uri /index.html;
}
}
NGINX
# Statiska filer från builden
COPY --from=build /app/dist /usr/share/nginx/html
# Hälsokoll (valfritt)
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD wget -qO- http://127.0.0.1/ || exit 1
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]