Skip to content

Commit

Permalink
Merge branch 'release/v0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jptrsn committed Mar 18, 2024
2 parents 76120e8 + 5a415dd commit 86eb05f
Show file tree
Hide file tree
Showing 171 changed files with 13,902 additions and 3,658 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches:
- 'develop'
paths:
- 'packages/signal/**/*'
- 'packages/server/**/*'

jobs:
push_to_registry:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/build-signal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Docker Image CI/CD Signal Server

on:
workflow_dispatch:
push:
branches:
- 'develop'
paths:
- 'packages/signal/**/*'

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: educoder/zip-captions-signal

- name: Build and push client Docker image
uses: docker/build-push-action@v4
with:
target: staging_signal
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request'}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
140 changes: 140 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Deploy Changed Project to Azure
on:
workflow_dispatch:
push:
branches:
- main
# pull_request:
# types: [opened, synchronize, reopened, closed]
# branches:
# - main

# Needed for nx-set-shas when run on the main branch
permissions:
actions: read
contents: read

jobs:
identify_affected:
runs-on: ubuntu-latest
outputs:
affected: ${{ steps.set-output.outputs.affected }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Dependencies
run: npm ci

- uses: nrwl/nx-set-shas@v4
with:
main-branch-name: 'main'
# This line is needed for nx affected to work when CI is running on a PR
- run: git branch --track main origin/main

- name: Identify affected projects
run: |
echo "AFFECTED=$(npx nx print-affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} | jq -r '.projects | join(" ")')" >> $GITHUB_ENV
- name: Set affected projects as output
id: set-output
run: echo "::set-output name=affected::${{ env.AFFECTED }}"

build_and_deploy_client:
if: contains(needs.identify_affected.outputs.affected, 'client')
needs: identify_affected
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Dependencies
run: npm ci

- name: Build Project
run: npm run build:client

- name: Deploy
id: deploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
app_location: '/docs' # App source code path

push_and_deploy_server:
if: contains(needs.identify_affected.outputs.affected, 'server')
needs: identify_affected
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: educoder/zip-captions-server

- name: Build and push server Docker image
uses: docker/build-push-action@v4
with:
target: prod_server
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request'}}
tags: educoder/zip-captions-server:${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}

- name: Log in to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Deploy to container app
uses: azure/container-apps-deploy-action@v2
with:
containerAppName: zip-captions-server
resourceGroup: ZipCaptions
imageToDeploy: educoder/zip-captions-server:${{ github.sha }}
targetPort: 3000
disableTelemetry: true
ingress: external
environmentVariables: >
MONGO_DB_USER=secretref:mongo-db-user
MONGO_DB_PASSWORD=secretref:mongo-db-password
MONGO_DB_URL=secretref:mongo-db-url
MONGO_DB_PORT=10255
MONGO_DB_NAME=secretref:mongo-db-name
AZURE_CLIENT_ID=secretref:azure-client-id
AZURE_CLIENT_SECRET=secretref:azure-client-secret
AZURE_REDIRECT_URI=secretref:azure-redirect-url
GOOGLE_CLIENT_ID=secretref:google-client-id
GOOGLE_CLIENT_SECRET=secretref:google-client-secret
GOOGLE_REDIRECT_URI=secretref:google-redirect-uri
SESSION_SECRET=secretref:session-secret
JWT_SECRET=secretref:jwt-secret
APP_ORIGIN=https://zipcaptions.app
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: 'close'
21 changes: 21 additions & 0 deletions .github/workflows/push-mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Push to GitLab Mirror

on:
workflow_dispatch:
push:

jobs:
push_to_mirror:
name: Push to GitLab Mirror
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Push to GitLab
uses: yesolutions/mirror-action@master
with:
REMOTE: 'https://gitlab.com/educoder/zip-captions.git'
GIT_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GIT_PASSWORD: ${{ secrets.GITLAB_PASSWORD }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ node_modules
*.launch
.settings/
*.sublime-workspace
.nx/*

# IDE - VSCode
.vscode/*
Expand All @@ -41,6 +42,7 @@ Thumbs.db
.angular
.env.*
.secret.env
.env.*

# Android Build
.gradle/*
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.tabSize": 2,
"editor.detectIndentation": false
}
39 changes: 26 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM $IMAGE as base_image
WORKDIR /usr/src/app
COPY package*.json .
ARG NX_NON_NATIVE_HASHER=true
RUN npm ci
RUN npm ci --ignore-scripts

# DEVELOPMENT
FROM base_image as dev
Expand All @@ -13,25 +13,32 @@ CMD [""]

# STAGING
FROM dev as staging_build_client
ENV ZIP_SOCKET_SERVER=https://socket.fartyparts.work
ENV ZIP_SOCKET_PORT=443
ENV ZIP_PEER_SERVER=peer.fartyparts.work
ENV ZIP_PEER_PORT=443
RUN npm run build:client
ENV ZIP_SOCKET_SERVER=wss://api.zipcaptions.app
ENV ZIP_PEER_SERVER=https://api.zipcaptions.app
ENV ZIP_PEER_PORT=3000
ENV ZIP_AUTH_API_URL=https://api.zipcaptions.app
ENV ZIP_AUTH_API_VERSION=v1
RUN npm run build:client:staging

FROM dev as staging_build_server
ENV ALLOWED_ORIGINS=https://fartyparts.work
FROM dev as staging_build_signal
RUN npm run build:signal

FROM dev as staging_build_server
RUN npm run build:server

FROM nginx:alpine as staging_client
COPY --from=staging_build_client /usr/src/app/docs /usr/share/nginx/html
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80 443

FROM staging_build_server as staging_server
FROM staging_build_signal as staging_signal
CMD ["node", "./dist/packages/signal/main.js"]
EXPOSE 3000 9000

FROM staging_build_server as staging_server
CMD ["node", "./dist/packages/server/main.js"]
EXPOSE 3000 9000

FROM dev as prod_build_client
ENV ZIP_SOCKET_SERVER=https://socket.zipcaptions.app
ENV ZIP_SOCKET_PORT=443
Expand All @@ -44,10 +51,16 @@ COPY --from=staging_build_client /usr/src/app/docs /usr/share/nginx/html
COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80

FROM dev as prod_build_server
ENV ALLOWED_ORIGINS=https://zipcaptions.app
FROM dev as prod_build_signal
RUN npm run build:signal

FROM staging_build_server as prod_server
FROM staging_build_signal as prod_signal
CMD ["node", "./dist/packages/signal/main.js"]
EXPOSE 3000 9000
EXPOSE 3000 9000

FROM dev as prod_build_server
RUN npm run build:server

FROM prod_build_server as prod_server
CMD ["node", "./dist/packages/server/main.js"]
EXPOSE 3000
Loading

0 comments on commit 86eb05f

Please sign in to comment.