Compare commits

..

2 Commits

Author SHA1 Message Date
1b74650aa2 Dockerfile upd drone-config
Some checks reported errors
continuous-integration/drone Build encountered an error
2025-10-09 15:02:36 +02:00
48214a305a .gitignore 2025-10-09 14:15:34 +02:00
4 changed files with 157 additions and 19 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
.git
.vscode
node_modules
.dist
dist
coverage
.vite
Dockerfile
.drone.yml

59
.drone.yml Normal file
View 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

43
.gitignore vendored
View File

@ -1,24 +1,29 @@
# Logs # dependencies
logs node_modules/
# builds
.dist/
dist/
.vite/
coverage/
# env
.env
.env.*
!.env.example
# editors / os
.DS_Store
.vscode/*
!.vscode/extensions.json
# logs
*.log *.log
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
pnpm-debug.log* pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

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;"]