Dockerfile upd drone-config
Some checks reported errors
continuous-integration/drone Build encountered an error
Some checks reported errors
continuous-integration/drone Build encountered an error
This commit is contained in:
9
.dockerignore
Normal file
9
.dockerignore
Normal file
@ -0,0 +1,9 @@
|
||||
.git
|
||||
.vscode
|
||||
node_modules
|
||||
.dist
|
||||
dist
|
||||
coverage
|
||||
.vite
|
||||
Dockerfile
|
||||
.drone.yml
|
||||
59
.drone.yml
Normal file
59
.drone.yml
Normal file
@ -0,0 +1,59 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: build-test-and-push
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
||||
branch:
|
||||
- main
|
||||
|
||||
steps:
|
||||
- name: install+lint+typecheck+test
|
||||
image: node:20-alpine
|
||||
environment:
|
||||
PNPM_HOME: /root/.local/share/pnpm
|
||||
commands:
|
||||
- corepack enable
|
||||
- corepack prepare pnpm@9.12.0 --activate
|
||||
- pnpm install --frozen-lockfile
|
||||
- pnpm lint
|
||||
- pnpm typecheck
|
||||
- pnpm test -- --run
|
||||
|
||||
- name: docker-push
|
||||
image: plugins/docker:latest
|
||||
settings:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
|
||||
# Registry och repo
|
||||
registry: rubble.se:5000
|
||||
repo: rubble.se:5000/urban/hemhub-web
|
||||
|
||||
# Inloggning (lägg in som secrets i Drone)
|
||||
username:
|
||||
from_secret: REGISTRY_USER
|
||||
password:
|
||||
from_secret: REGISTRY_PASS
|
||||
|
||||
# Bygg-args till Dockerfile (Vite läser dem vid build)
|
||||
build_args:
|
||||
- VITE_API_BASE_URL=${VITE_API_BASE_URL}
|
||||
- VITE_BASE_PATH=/hemhub/
|
||||
|
||||
# Taggar
|
||||
tags:
|
||||
- latest
|
||||
- ${DRONE_COMMIT_SHA:0:7}
|
||||
|
||||
# Sätt till false/ta bort om ditt registry har TLS
|
||||
insecure: true
|
||||
|
||||
environment:
|
||||
# Drone-secret för backend-url, sätt i UI under repo -> Secrets
|
||||
VITE_API_BASE_URL:
|
||||
from_secret: VITE_API_BASE_URL
|
||||
|
||||
depends_on:
|
||||
- install+lint+typecheck+test
|
||||
65
Dockerfile
Normal file
65
Dockerfile
Normal 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;"]
|
||||
Reference in New Issue
Block a user