Add woodpecker yaml and Dockerfile

This commit is contained in:
dvirlabs 2025-06-13 18:01:03 +03:00
parent ab14a59235
commit 04d0d3cd26
6 changed files with 95 additions and 0 deletions

12
.woodpecker.yaml Normal file
View File

@ -0,0 +1,12 @@
pipeline:
build-frontend:
when:
path:
include: [ frontend/** ]
# same frontend build step
build-backend:
when:
path:
include: [ backend/** ]
# same backend build step

22
backend/.woodpecker.yaml Normal file
View File

@ -0,0 +1,22 @@
when:
path:
include:
- backend/**
pipeline:
build-backend:
image: gcr.io/kaniko-project/executor:latest
environment:
DOCKER_CONFIG: /kaniko/.docker/
volumes:
- name: docker-config
path: /kaniko/.docker/
commands:
- echo "{\"auths\":{\"https://harbor.dvirlabs.com\":{\"username\":\"${DOCKER_USERNAME}\",\"password\":\"${DOCKER_PASSWORD}\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor \
--dockerfile=Dockerfile \
--context=. \
--destination=harbor.dvirlabs.com/labmap/backend:latest
volumes:
- name: docker-config
temp: {}

12
backend/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
# backend/Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
EXPOSE 8000

22
frontend/.woodpecker.yaml Normal file
View File

@ -0,0 +1,22 @@
when:
path:
include:
- frontend/**
pipeline:
build-frontend:
image: gcr.io/kaniko-project/executor:latest
environment:
DOCKER_CONFIG: /kaniko/.docker/
volumes:
- name: docker-config
path: /kaniko/.docker/
commands:
- echo "{\"auths\":{\"https://harbor.dvirlabs.com\":{\"username\":\"${DOCKER_USERNAME}\",\"password\":\"${DOCKER_PASSWORD}\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor \
--dockerfile=Dockerfile \
--context=. \
--destination=harbor.dvirlabs.com/labmap/frontend:latest
volumes:
- name: docker-config
temp: {}

16
frontend/Dockerfile Normal file
View File

@ -0,0 +1,16 @@
# frontend/Dockerfile
FROM node:20 AS builder
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
# Serve with nginx
FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

11
frontend/nginx.conf Normal file
View File

@ -0,0 +1,11 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
}