feat: Add Dockerfiles for jobs/leads services and build scripts
Some checks failed
build-all / build-gateway (push) Failing after 1s
build-images / gateway (push) Failing after 1s
build-all / build-users (push) Failing after 1s
build-all / build-cron (push) Failing after 2s
build-gateway / build (push) Failing after 4s
build-services / build-gateway (push) Failing after 3s
build-services / build-users (push) Failing after 5s
build-services / build-jobs (push) Failing after 3s
build-and-push / detect-changes (push) Successful in 8s
build-services / build-cron (push) Failing after 2s
build-services / build-leads (push) Failing after 4s
build-all-services / build (push) Failing after 3s
build-and-push / build (cron) (push) Failing after 5s
build-and-push / build (customers) (push) Failing after 3s
build-and-push / build (employees) (push) Failing after 3s
build-and-push / build (developers) (push) Failing after 3s
build-and-push / build (fitness-trainers) (push) Failing after 4s
build-and-push / build (gateway) (push) Failing after 3s
build-and-push / build (graphic-designers) (push) Failing after 3s
build-and-push / build (job-seekers) (push) Failing after 3s
build-and-push / build (jobs) (push) Failing after 2s
build-and-push / build (leads) (push) Failing after 2s
build-and-push / build (makeup-artists) (push) Failing after 2s
build-and-push / build (payments) (push) Failing after 2s
build-and-push / build (photographers) (push) Failing after 3s
build-and-push / build (social-media-managers) (push) Failing after 3s
build-and-push / build (tutors) (push) Failing after 3s
build-and-push / build (ugc-content-creators) (push) Failing after 2s
build-and-push / build (users) (push) Failing after 2s
build-and-push / build (video-editors) (push) Failing after 2s
build-and-push / build (companies) (push) Failing after 10m52s
build-and-push / build (catering-services) (push) Successful in 11m29s

Add build-images.yaml for Forgejo CI
tmp build.yaml
Add Dockerfiles for jobs and leads services
Add build-all.sh script for batch building
This commit is contained in:
Ashwin Kumar Sivakumar 2026-06-13 18:31:34 +05:30
parent 189f4bca60
commit 1c9b4848a9
5 changed files with 304 additions and 0 deletions

View file

@ -0,0 +1,19 @@
name: build-images
on:
push:
branches:
- high-performance
jobs:
gateway:
runs-on: ubuntu-latest
container:
image: registry.nxtgauge.com/rust:alpine
steps:
- name: checkout
run: apk add --no-cache git && git clone --depth 1 http://forgejo-http.forgejo.svc.cluster.local:3000/ashwin/nxtgauge-backend-rust.git /src
- name: build
run: cd /src && cargo build --release --bin gateway
- name: package
run: cp /src/target/release/gateway /gateway && echo "Gateway built"

116
.gitea/workflows/build.yaml Normal file
View file

@ -0,0 +1,116 @@
name: Build Backend And Update GitOps
on:
push:
branches:
- main
- high-performance
jobs:
build:
runs-on: ubuntu-latest
env:
DOCKER_HOST: unix:///var/run/docker.sock
strategy:
fail-fast: false
matrix:
include:
- app_dir: apps/catering_services
image: registry.nxtgauge.com/nxtgauge-rust-catering-services
- app_dir: apps/companies
image: registry.nxtgauge.com/nxtgauge-rust-companies
- app_dir: apps/cron
image: registry.nxtgauge.com/nxtgauge-rust-cron
- app_dir: apps/customers
image: registry.nxtgauge.com/nxtgauge-rust-customers
- app_dir: apps/developers
image: registry.nxtgauge.com/nxtgauge-rust-developers
- app_dir: apps/employees
image: registry.nxtgauge.com/nxtgauge-rust-employees
- app_dir: apps/fitness_trainers
image: registry.nxtgauge.com/nxtgauge-rust-fitness-trainers
- app_dir: apps/gateway
image: registry.nxtgauge.com/nxtgauge-rust-gateway
- app_dir: apps/graphic_designers
image: registry.nxtgauge.com/nxtgauge-rust-graphic-designers
- app_dir: apps/jobs
image: registry.nxtgauge.com/nxtgauge-rust-jobs
- app_dir: apps/job_seekers
image: registry.nxtgauge.com/nxtgauge-rust-job-seekers
- app_dir: apps/leads
image: registry.nxtgauge.com/nxtgauge-rust-leads
- app_dir: apps/makeup_artists
image: registry.nxtgauge.com/nxtgauge-rust-makeup-artists
- app_dir: apps/payments
image: registry.nxtgauge.com/nxtgauge-rust-payments
- app_dir: apps/photographers
image: registry.nxtgauge.com/nxtgauge-rust-photographers
- app_dir: apps/social_media_managers
image: registry.nxtgauge.com/nxtgauge-rust-social-media-managers
- app_dir: apps/tutors
image: registry.nxtgauge.com/nxtgauge-rust-tutors
- app_dir: apps/ugc_content_creators
image: registry.nxtgauge.com/nxtgauge-rust-ugc-content-creators
- app_dir: apps/users
image: registry.nxtgauge.com/nxtgauge-rust-users
- app_dir: apps/video_editors
image: registry.nxtgauge.com/nxtgauge-rust-video-editors
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Docker CLI
run: |
apt-get update
apt-get install -y docker.io
- name: Log in to registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login registry.nxtgauge.com -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Build and push backend service image
run: |
set -euo pipefail
IMAGE_SHA="${{ matrix.image }}:${{ github.sha }}"
IMAGE_LATEST="${{ matrix.image }}:latest"
docker build -f "${{ matrix.app_dir }}/Dockerfile" -t "${IMAGE_SHA}" -t "${IMAGE_LATEST}" .
docker push "${IMAGE_SHA}"
docker push "${IMAGE_LATEST}"
update-gitops:
needs: build
runs-on: ubuntu-latest
steps:
- name: Update GitOps backend tags
env:
GITOPS_USERNAME: ${{ secrets.GITOPS_GITHUB_USERNAME || 'Traceworks2023' }}
GITOPS_PASSWORD: ${{ secrets.GITOPS_GITHUB_TOKEN || secrets.GITOPS_PAT }}
GITOPS_REPO: https://github.com/Traceworks2023/nxtgauge-gitops.git
IMAGE_TAG: ${{ github.sha }}
run: |
set -euo pipefail
test -n "${GITOPS_PASSWORD:-}" || { echo "GITOPS_PASSWORD is empty"; exit 1; }
AUTH="$(printf '%s' "${GITOPS_USERNAME}:${GITOPS_PASSWORD}" | base64 -w0)"
TMP_DIR="$(mktemp -d)"
git -c http.extraHeader="AUTHORIZATION: basic ${AUTH}" clone --branch main "${GITOPS_REPO}" "${TMP_DIR}"
cd "${TMP_DIR}"
python3 - <<'PY'
from pathlib import Path
import os
path = Path('apps/nxtgauge-backend-rust/overlays/prod/kustomization.yaml')
lines = path.read_text().splitlines()
out = []
for line in lines:
if line.strip().startswith('newTag:'):
indent = line[:len(line) - len(line.lstrip())]
out.append(f"{indent}newTag: {os.environ['IMAGE_TAG']}")
else:
out.append(line)
path.write_text('\n'.join(out) + '\n')
PY
git config user.name "forgejo-actions"
git config user.email "forgejo-actions@nxtgauge.com"
git add apps/nxtgauge-backend-rust/overlays/prod/kustomization.yaml
git diff --cached --quiet && exit 0
git commit -m "chore(gitops): update backend images to ${IMAGE_TAG}"
git -c http.extraHeader="AUTHORIZATION: basic ${AUTH}" push origin main

28
apps/jobs/Dockerfile Normal file
View file

@ -0,0 +1,28 @@
FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin jobs --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime
RUN apk add --no-cache ca-certificates
RUN adduser -D -u 1000 appuser
WORKDIR /app
COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-musl/release/jobs ./jobs
USER appuser
CMD ["./jobs"]

28
apps/leads/Dockerfile Normal file
View file

@ -0,0 +1,28 @@
FROM rust:alpine AS builder
WORKDIR /usr/src/app
RUN apk add --no-cache musl-dev pkgconfig openssl-dev openssl-libs-static && \
rustup target add x86_64-unknown-linux-musl
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY apps ./apps
ENV RUSTFLAGS='-C target-feature=+crt-static'
ENV OPENSSL_STATIC=1
ENV OPENSSL_DIR=/usr
RUN cargo build --release --bin leads --target x86_64-unknown-linux-musl
FROM alpine:latest AS runtime
RUN apk add --no-cache ca-certificates
RUN adduser -D -u 1000 appuser
WORKDIR /app
COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-musl/release/leads ./leads
USER appuser
CMD ["./leads"]

113
scripts/build-all.sh Executable file
View file

@ -0,0 +1,113 @@
#!/bin/bash
# build-all.sh - Build all nxtgauge backend services and push to registry
# Usage: ./scripts/build-all.sh [TAG]
set -e
REGISTRY="registry.nxtgauge.com"
TAG=${1:-$(git rev-parse --short HEAD)}
DOCKERFILE="Dockerfile.simple"
echo "============================================"
echo "🚀 NXTGAUGE Full Rebuild Script"
echo "============================================"
echo "Registry: ${REGISTRY}"
echo "Tag: ${TAG}"
echo "Dockerfile: ${DOCKERFILE}"
echo ""
# Services list with underscores (matching Cargo.toml bin names)
SERVICES=(
"gateway"
"users"
"companies"
"job_seekers"
"customers"
"photographers"
"makeup_artists"
"tutors"
"developers"
"video_editors"
"graphic_designers"
"social_media_managers"
"fitness_trainers"
"catering_services"
"ugc_content_creators"
"employees"
"payments"
"jobs"
"leads"
"cron"
)
# Also need service names with hyphens for image names
declare -A SERVICE_IMAGE_NAMES=(
["gateway"]="nxtgauge-rust-gateway"
["users"]="nxtgauge-rust-users"
["companies"]="nxtgauge-rust-companies"
["job_seekers"]="nxtgauge-rust-job-seekers"
["customers"]="nxtgauge-rust-customers"
["photographers"]="nxtgauge-rust-photographers"
["makeup_artists"]="nxtgauge-rust-makeup-artists"
["tutors"]="nxtgauge-rust-tutors"
["developers"]="nxtgauge-rust-developers"
["video_editors"]="nxtgauge-rust-video-editors"
["graphic_designers"]="nxtgauge-rust-graphic-designers"
["social_media_managers"]="nxtgauge-rust-social-media-managers"
["fitness_trainers"]="nxtgauge-rust-fitness-trainers"
["catering_services"]="nxtgauge-rust-catering-services"
["ugc_content_creators"]="nxtgauge-rust-ugc-content-creators"
["employees"]="nxtgauge-rust-employees"
["payments"]="nxtgauge-rust-payments"
["jobs"]="nxtgauge-rust-jobs"
["leads"]="nxtgauge-rust-leads"
["cron"]="nxtgauge-rust-cron"
)
TOTAL=${#SERVICES[@]}
CURRENT=0
build_service() {
local service=$1
local image_name=${SERVICE_IMAGE_NAMES[$service]}
local tag="${REGISTRY}/${image_name}:${TAG}"
local latest="${REGISTRY}/${image_name}:latest"
CURRENT=$((CURRENT + 1))
echo ""
echo "[$CURRENT/$TOTAL] Building ${image_name}..."
echo " Service: ${service}"
echo " Tag: ${tag}"
# Build
docker build \
--build-arg SERVICE_NAME=${service} \
-f ${DOCKERFILE} \
-t ${tag} \
-t ${latest} \
. 2>&1 | tail -5
# Push
echo " Pushing..."
docker push ${tag}
docker push ${latest}
echo "${image_name} complete"
}
# Build all services
for service in "${SERVICES[@]}"; do
build_service "${service}"
done
echo ""
echo "============================================"
echo "🎉 All services built and pushed!"
echo "============================================"
echo "Tag used: ${TAG}"
echo ""
echo "Update kustomization.yaml with:"
for service in "${SERVICES[@]}"; do
local image_name=${SERVICE_IMAGE_NAMES[$service]}
echo " ${image_name}: ${TAG}"
done