Skip to content

Commit

Permalink
Merge pull request #242 from GeorgeWalker/master
Browse files Browse the repository at this point in the history
GitHub Actions, Dockerfiles and changes needed for Emerald
  • Loading branch information
GeorgeWalker authored Oct 23, 2024
2 parents da2213f + 816798a commit 736a90b
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 59 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/api-dotnetcore.yml

This file was deleted.

72 changes: 72 additions & 0 deletions .github/workflows/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: API

on:
workflow_dispatch:
env:
IMAGE_NAME: api
WORKING_DIRECTORY: ./
jobs:
build:
runs-on: ubuntu-latest

steps:

- name: Checkout Repo
uses: actions/checkout@v4

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

# Get SHORT_SHA to tag images
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"
- name: Docker Build Image
run: |
docker build --tag ${{ env.IMAGE_NAME }} -f api/Dockerfile .
docker tag ${{ env.IMAGE_NAME }} artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }}
docker push artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }}
- name: Checkout ArgoCD Repo
id: gitops
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-cb6495
ref: develop
token: ${{ secrets.GIT_OPS_SSH_KEY }} # `GH_PAT` is a secret that contains your PAT
path: gitops

- name: Update Helm Values and Commit
id: helm
if: steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
run: |
# Clone the GitOps deployment configuration repository
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and
cd gitops/charts
# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
sed -i "s/apitag: .*/apitag: dev-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/dev_values.yaml
sed -i "s/apitag: .*/apitag: dev-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" api/values.yaml
# Commit and push the changes
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
git add ../deploy/dev_values.yaml
git commit -m "Update API image tag"
git push origin develop # Update the branch name as needed
30 changes: 0 additions & 30 deletions .github/workflows/app-vue.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Backup

on:
workflow_dispatch:
env:
IMAGE_NAME: backup
WORKING_DIRECTORY: ./
jobs:
build:
runs-on: ubuntu-latest

steps:

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Checkout Backup Container Repo
id: gitops
uses: actions/checkout@v4
with:
repository: BCDevOps/backup-container.git
ref: 2.9.0

- name: Docker Build Backup Image
run: |
cd docker
docker build --tag ${{ env.IMAGE_NAME }} .
docker tag ${{ env.IMAGE_NAME }} artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}:latest
docker push artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}
34 changes: 34 additions & 0 deletions .github/workflows/schema-spy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Schema-Spy

on:
workflow_dispatch:
env:
IMAGE_NAME: schema-spy
WORKING_DIRECTORY: ./
jobs:
build:
runs-on: ubuntu-latest

steps:

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Checkout Schema Spy Repo
id: gitops
uses: actions/checkout@v4
with:
repository: bcgov/SchemaSpy.git
ref: master

- name: Docker Build Schema Spy Image
run: |
docker build --tag ${{ env.IMAGE_NAME }} .
docker tag ${{ env.IMAGE_NAME }} artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}:latest
docker push artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}
72 changes: 72 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Web

on:
workflow_dispatch:
env:
IMAGE_NAME: web
WORKING_DIRECTORY: ./
jobs:
builds:
runs-on: ubuntu-latest

steps:
- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Checkout Repo
uses: actions/checkout@v4

# Get SHORT_SHA to tag images
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"
- name: Docker Build Image
run: |
docker build --tag nginx-runtime -f docker/nginx-runtime/Dockerfile ./docker/nginx-runtime/
cd web
docker build --tag ss-web-artifacts -f Dockerfile.node . --build-arg WEB_BASE_HREF=${{ vars.WEB_BASE_HREF }}
cd ..
docker build --tag ${{ env.IMAGE_NAME }} -f docker/vue-on-nginx/Dockerfile ./docker/vue-on-nginx/
docker tag ${{ env.IMAGE_NAME }} artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }}
docker push artifacts.developer.gov.bc.ca/ccb6-images/${{ env.IMAGE_NAME }}:dev-${{ steps.short_sha.outputs.SHORT_SHA }}
- name: Checkout ArgoCD Repo
id: gitops
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-cb6495
ref: develop
token: ${{ secrets.GIT_OPS_SSH_KEY }} # `GH_PAT` is a secret that contains your PAT
path: gitops

- name: Update Helm Values and Commit
id: helm
if: steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
run: |
# Clone the GitOps deployment configuration repository
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and
cd gitops/charts
# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
sed -i "s/webtag: .*/webtag: dev-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/dev_values.yaml
sed -i "s/webtag: .*/webtag: dev-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" web/values.yaml
# Commit and push the changes
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
git add ../deploy/dev_values.yaml
git commit -m "Update Dev Web image tag"
git push origin develop # Update the branch name as needed
30 changes: 30 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_URLS=http://*:8080
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENV DOTNET_gcServer=1
ARG VERSION
ENV VERSION=$VERSION

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build

WORKDIR /src

COPY ["api/api.csproj", "api/"]
COPY ["db/db.csproj", "db/"]
RUN dotnet restore api/api.csproj
RUN dotnet restore db/db.csproj
COPY . .
RUN dotnet build "api/api.csproj" -c Release
# build
FROM build AS publish
RUN dotnet publish "api/api.csproj" -c Release -o /app/publish --runtime linux-musl-x64 --no-self-contained

FROM base AS final

# copy app
WORKDIR /app
COPY --from=publish /app/publish .
COPY --from=build /src/db/sql /src/db/sql
ENTRYPOINT ["dotnet", "api.dll"]
10 changes: 10 additions & 0 deletions web/Dockerfile.node
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM centos/nodejs-10-centos7:10
ARG WEB_BASE_HREF
ENV WEB_BASE_HREF="$WEB_BASE_HREF"
ENV WEB1_BASE_HREF="$WEB_BASE_HREF"
WORKDIR /opt/app-root/src
COPY . .
RUN echo "$WEB1_BASE_HREF"
RUN echo "$WEB_BASE_HREF"
RUN npm install
RUN npm run build

0 comments on commit 736a90b

Please sign in to comment.