diff --git a/.drone.yml b/.drone.yml index e4ab759..965eae5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,8 +30,55 @@ steps: exit 1 - git checkout "$DRONE_COMMIT" - - name: Build and test frontend image + - name: install-frontend-deps + image: node:24-alpine + depends_on: + - clone + environment: + NODE_OPTIONS: "--max-old-space-size=1024" + commands: + - cd frontend && npm ci + + - name: test-shard-1 + image: node:24-alpine + depends_on: + - install-frontend-deps + environment: + NODE_OPTIONS: "--max-old-space-size=1024" + commands: + - cd frontend && npx vitest run --reporter=verbose --shard=1/4 + + - name: test-shard-2 + image: node:24-alpine + depends_on: + - install-frontend-deps + environment: + NODE_OPTIONS: "--max-old-space-size=1024" + commands: + - cd frontend && npx vitest run --reporter=verbose --shard=2/4 + + - name: test-shard-3 + image: node:24-alpine + depends_on: + - install-frontend-deps + environment: + NODE_OPTIONS: "--max-old-space-size=1024" + commands: + - cd frontend && npx vitest run --reporter=verbose --shard=3/4 + + - name: test-shard-4 + image: node:24-alpine + depends_on: + - install-frontend-deps + environment: + NODE_OPTIONS: "--max-old-space-size=1024" + commands: + - cd frontend && npx vitest run --reporter=verbose --shard=4/4 + + - name: build-frontend-image image: plugins/kaniko + depends_on: + - clone resources: limits: memory: 2048MiB @@ -42,6 +89,7 @@ steps: repo: viktorbarzin/immoweb dockerfile: frontend/Dockerfile context: frontend + target: production enable_cache: true cache_repo: viktorbarzin/immoweb-cache tags: @@ -50,12 +98,20 @@ steps: - name: Update deployment image: alpine + depends_on: + - test-shard-1 + - test-shard-2 + - test-shard-3 + - test-shard-4 + - build-frontend-image commands: - apk add curl - 'curl -s -X PATCH "https://kubernetes:6443/apis/apps/v1/namespaces/realestate-crawler/deployments/realestate-crawler-ui" -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" -k -d ''[{"op":"replace","path":"/spec/template/spec/containers/0/image","value":"viktorbarzin/immoweb:''"$DRONE_BUILD_NUMBER"''"}]'' | head' - name: verify-deploy image: alpine + depends_on: + - Update deployment commands: - apk add --no-cache curl jq - | diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 6b403a7..f848505 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -30,7 +30,7 @@ COPY . . RUN npx vite build # Stage 4: Serve with nginx -FROM nginx:alpine +FROM nginx:alpine AS production # Remove default nginx static files RUN rm -rf /usr/share/nginx/html/*