Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initContainer for more independent builds #345

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: data CD

on:
push:
workflow_dispatch:

jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
data: ${{ steps.filter.outputs.data }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
# the server is required in data, since apparently it is impossibly to schedule a job after another in GitHub
filters: |
data:
- '.github/**'
- 'data/**'
data-build:
needs:
- changes
if: ${{ needs.changes.outputs.data == 'true' }}
uses: ./.github/workflows/docker-build.yml
with:
image_suffix: data
context: ./data
dockerfile: Dockerfile
permissions:
contents: read
packages: write
data-deployment:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- data-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run navigatum-prod restart --kind Deployment --resource-name data --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}
data-staging-deployment:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- data-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run pr-${{github.event.number}} restart --kind Deployment --resource-name data --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}
40 changes: 11 additions & 29 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
data: ${{ steps.filter.outputs.data_server }}
server: ${{ steps.filter.outputs.data_server }}
steps:
- uses: actions/checkout@v3
Expand All @@ -23,46 +22,27 @@ jobs:
- '.github/**'
- 'data/**'
- 'server/**'
data-build:
server-build:
uses: ./.github/workflows/docker-build.yml
needs:
- changes
if: ${{ needs.changes.outputs.data == 'true' }}
uses: ./.github/workflows/docker-build.yml
if: ${{ needs.changes.outputs.server == 'true' }}
with:
image_suffix: data
context: ./data
dockerfile: Dockerfile
image_suffix: server
context: ./server
dockerfile: Dockerfile.server
permissions:
contents: read
packages: write
data-deployment:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- data-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run navigatum-prod restart --kind Deployment --resource-name data --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}
- run: sleep 5
data-staging-deployment:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- data-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
- run: argocd app actions run pr-${{github.event.number}} restart --kind Deployment --resource-name data --auth-token ${{ secrets.ARGOCD_TOKEN }} --server ${{ secrets.ARGOCD_SERVER }}
- run: sleep 5
server-build:
server-init-build:
uses: ./.github/workflows/docker-build.yml
needs:
- data-deployment
- changes
if: ${{ needs.changes.outputs.server == 'true' }}
with:
image_suffix: server
image_suffix: server-init
context: ./server
dockerfile: Dockerfile.server
dockerfile: Dockerfile.dbinit
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -111,6 +91,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- server-build
- server-init-build
- mieli-search-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
Expand All @@ -120,6 +101,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- server-build
- server-init-build
- mieli-search-build
steps:
- run: curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 && chmod +x /usr/local/bin/argocd
Expand Down
4 changes: 2 additions & 2 deletions deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ The documentation for the specific sub-services can be found in the respective d
## General description

The general request-Flowchart is the following:
![Flowchart, on how the requests are routed](../resources/deployment/Flowchart.svg)
![Flowchart, on how the requests are routed](../resources/deployment/Flowchart.png)

The project is layed out in this sense:
![deployment diagram, of how the different components interact](../resources/deployment/Deployment_Overview.svg)
![deployment diagram, of how the different components interact](../resources/deployment/Deployment_Overview.png)

Genreral information:

Expand Down
6 changes: 6 additions & 0 deletions deployment/k3s/templates/deployments/server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ spec:
volumes:
- name: tmp-server
emptyDir: {}
initContainers:
- name: server-init-db
image: "ghcr.io/tum-dev/navigatum-server-init:{{ .Values.branch }}"
containers:
- name: server
image: "ghcr.io/tum-dev/navigatum-server:{{ .Values.branch }}"
Expand All @@ -36,6 +39,9 @@ spec:
- secretRef:
name: server-api-keys # MEILI_MASTER_KEY
{{ end }}
env:
- name: DB_LOCATION
value: /tmp/server.db
ports:
- containerPort: 8080
name: api
Expand Down
Loading