From e6d6673d848230f02e3637519bf298cbe05c453e Mon Sep 17 00:00:00 2001 From: gitadmin Date: Wed, 22 Jul 2026 05:47:02 +0000 Subject: [PATCH 1/6] Add Dockerfile --- Dockerfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c4055afc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# ----- Stage 1: Build Angular SSR App ----- +FROM node:22-alpine AS build +WORKDIR /app + +# Copy package files +COPY package.json package-lock.json ./ + +# Install dependencies (cached if package files haven't changed) +RUN npm ci + +# Copy the rest of the code (including the environment.ts injected by Gitea Actions) +COPY . . + +# Build the Angular app for production +RUN npm run build + +# ----- Stage 2: Serve SSR App ----- +FROM node:22-alpine AS final + +WORKDIR /app + +# Copy the built assets from the build stage. +# Your angular.json defines the base output path as "preview" +COPY --from=build /app/preview ./preview + +# Expose the standard Angular SSR port +EXPOSE 4000 + +# Start the Node.js SSR server +# Note: Angular 17+ SSR usually outputs the server file to /server/server.mjs +CMD ["node", "preview/server/server.mjs"] \ No newline at end of file From 7dfb81d2de0c92a3abab0c41136309ef60801c5d Mon Sep 17 00:00:00 2001 From: gitadmin Date: Wed, 22 Jul 2026 05:49:14 +0000 Subject: [PATCH 2/6] Add .gitea/workflows/docker-publish.yaml --- .gitea/workflows/docker-publish.yaml | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .gitea/workflows/docker-publish.yaml diff --git a/.gitea/workflows/docker-publish.yaml b/.gitea/workflows/docker-publish.yaml new file mode 100644 index 00000000..47e71bc8 --- /dev/null +++ b/.gitea/workflows/docker-publish.yaml @@ -0,0 +1,88 @@ +name: Docker Build & Publish UI + +on: + push: + branches: [ prod, dev ] + +env: + REGISTRY: gitea.biz360.me + IMAGE_NAME: ${{ github.repository }} + PROJECT_SECRET_KEY: "MASTERADMINUI" + # Target the base environment file directly + ENV_FILE_PATH: "src/environments/environment.ts" + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Determine Environment + id: env_config + run: | + if [[ "${GITHUB_REF##*/}" == "dev" ]]; then + echo "INFISICAL_ENV=dev" >> $GITHUB_OUTPUT + elif [[ "${GITHUB_REF##*/}" == "prod" ]]; then + echo "INFISICAL_ENV=prod" >> $GITHUB_OUTPUT + fi + + - name: Fetch secrets from Infisical + uses: Infisical/secrets-action@v1.0.9 + with: + client-id: ${{ secrets.INFISICAL_CLIENT_ID }} + client-secret: ${{ secrets.INFISICAL_CLIENT_SECRET }} + env-slug: ${{ steps.env_config.outputs.INFISICAL_ENV }} + project-slug: "syscom-xpq-0" + domain: "https://infisical.biz360.me/" + export-type: "file" + file-output-path: "/infisical.env" + + - name: Brute-force overwrite environment.ts + run: | + source infisical.env + + # Forcefully overwrite the file the developers are importing + echo "${!PROJECT_SECRET_KEY}" > "$ENV_FILE_PATH" + + # Clean up + rm -f infisical.env + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.REGISTRY_TOKEN }} + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=raw,value=dev-{{date 'YYYYMMDDTHHmm'}},enable=${{ github.ref == 'refs/heads/dev' }} + type=raw,value=prod-{{date 'YYYYMMDDTHHmm'}},enable=${{ github.ref == 'refs/heads/prod' }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Optional: Revert the file so the runner stays completely clean + - name: Clean up modified workspace + if: always() + run: git checkout -- "$ENV_FILE_PATH" \ No newline at end of file From 75d76dbc2bd29b659110628fd7a930989ce42b04 Mon Sep 17 00:00:00 2001 From: gitadmin Date: Wed, 22 Jul 2026 05:51:45 +0000 Subject: [PATCH 3/6] Delete Dockerfile --- Dockerfile | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c4055afc..00000000 --- a/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -# ----- Stage 1: Build Angular SSR App ----- -FROM node:22-alpine AS build -WORKDIR /app - -# Copy package files -COPY package.json package-lock.json ./ - -# Install dependencies (cached if package files haven't changed) -RUN npm ci - -# Copy the rest of the code (including the environment.ts injected by Gitea Actions) -COPY . . - -# Build the Angular app for production -RUN npm run build - -# ----- Stage 2: Serve SSR App ----- -FROM node:22-alpine AS final - -WORKDIR /app - -# Copy the built assets from the build stage. -# Your angular.json defines the base output path as "preview" -COPY --from=build /app/preview ./preview - -# Expose the standard Angular SSR port -EXPOSE 4000 - -# Start the Node.js SSR server -# Note: Angular 17+ SSR usually outputs the server file to /server/server.mjs -CMD ["node", "preview/server/server.mjs"] \ No newline at end of file From 208ea30e57cab7c508f76b149a67756c3759c3ea Mon Sep 17 00:00:00 2001 From: gitadmin Date: Wed, 22 Jul 2026 05:52:03 +0000 Subject: [PATCH 4/6] Add docker/Dockerfile --- docker/Dockerfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 docker/Dockerfile diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..c4055afc --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,31 @@ +# ----- Stage 1: Build Angular SSR App ----- +FROM node:22-alpine AS build +WORKDIR /app + +# Copy package files +COPY package.json package-lock.json ./ + +# Install dependencies (cached if package files haven't changed) +RUN npm ci + +# Copy the rest of the code (including the environment.ts injected by Gitea Actions) +COPY . . + +# Build the Angular app for production +RUN npm run build + +# ----- Stage 2: Serve SSR App ----- +FROM node:22-alpine AS final + +WORKDIR /app + +# Copy the built assets from the build stage. +# Your angular.json defines the base output path as "preview" +COPY --from=build /app/preview ./preview + +# Expose the standard Angular SSR port +EXPOSE 4000 + +# Start the Node.js SSR server +# Note: Angular 17+ SSR usually outputs the server file to /server/server.mjs +CMD ["node", "preview/server/server.mjs"] \ No newline at end of file From 6220134f179b6c6df52790afecbb29814e5da6be Mon Sep 17 00:00:00 2001 From: gitadmin Date: Wed, 22 Jul 2026 06:13:25 +0000 Subject: [PATCH 5/6] Update docker/Dockerfile --- docker/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c4055afc..ec357492 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -20,12 +20,10 @@ FROM node:22-alpine AS final WORKDIR /app # Copy the built assets from the build stage. -# Your angular.json defines the base output path as "preview" COPY --from=build /app/preview ./preview # Expose the standard Angular SSR port EXPOSE 4000 # Start the Node.js SSR server -# Note: Angular 17+ SSR usually outputs the server file to /server/server.mjs CMD ["node", "preview/server/server.mjs"] \ No newline at end of file From 792dd1eb76232d1f00141bd9b575e7fd25a97e12 Mon Sep 17 00:00:00 2001 From: gitadmin Date: Wed, 22 Jul 2026 06:18:26 +0000 Subject: [PATCH 6/6] Update docker/Dockerfile --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ec357492..bfa4810c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app # Copy package files COPY package.json package-lock.json ./ -# Install dependencies (cached if package files haven't changed) +# Install dependencies RUN npm ci # Copy the rest of the code (including the environment.ts injected by Gitea Actions)