Skip to content

Commit 2be83fb

Browse files
authored
Merge pull request #9 from leibniz-psychology/development
Fix Main Deployment
2 parents 16d74ea + 9f9ad84 commit 2be83fb

3 files changed

Lines changed: 130 additions & 4 deletions

File tree

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Deploy to AKS (dev)
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ staging ]
7+
8+
jobs:
9+
build:
10+
name: Deploy to AKS
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
env:
15+
GH_BRANCH: ${{ github.ref_name }}
16+
GH_SHA: ${{ github.sha }}
17+
NAMESPACE: staging
18+
APP: fearbase/ocpu
19+
REGISTRY: ${{ secrets.ACR_NAME }}.azurecr.io
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v2
23+
with:
24+
ref: 'staging'
25+
26+
# - name: Construct image ref
27+
# run: echo "IMAGE_REF=${REGISTRY}/${GITHUB_REPOSITORY,,}/${APP}:$(cat ${APP}/VERSION)" >> $GITHUB_ENV
28+
29+
- name: Azure Login
30+
uses: azure/login@v1
31+
with:
32+
creds: "${{ secrets.AZURE_CREDENTIALS }}"
33+
34+
- name: Connect to Azure Container Registry (ACR)
35+
run: |
36+
az acr login --name ${{ secrets.ACR_NAME }}
37+
38+
- name: Create php image build based on staging and push to a Azure Container Registry (ACR)
39+
if: github.ref_name == 'staging' && success()
40+
run: |
41+
DOCKER_BUILDKIT=1 docker build . -t ${{ secrets.ACR_NAME }}.azurecr.io/${{ env.APP }}:${{ github.sha }} \
42+
--build-arg OCPU_PASS=${{ secrets.OCPU_PASS}} \
43+
--build-arg SSL_KEY=${{ secrets.SSL_KEY}} \
44+
--file .github/workflows/manifests/staging/opencpu/Dockerfile
45+
docker push ${{ secrets.ACR_NAME }}.azurecr.io/${{ env.APP }}:${{ github.sha }}
46+
47+
- name: set tag latest-stg
48+
run: |
49+
docker pull ${{ secrets.ACR_NAME }}.azurecr.io/${{ env.APP }}:${{ github.sha }}
50+
docker tag ${{ secrets.ACR_NAME }}.azurecr.io/${{ env.APP }}:${{ github.sha }} ${{ secrets.ACR_NAME }}.azurecr.io/${{ env.APP }}:latest-stg
51+
docker push ${{ secrets.ACR_NAME }}.azurecr.io/${{ env.APP }}:latest-stg
52+
kustomize:
53+
name: kustomize
54+
runs-on: ubuntu-latest
55+
needs: build
56+
permissions:
57+
contents: read
58+
env:
59+
APP: fearbase/ocpu
60+
steps:
61+
- name: Check out the repo
62+
uses: actions/checkout@v3
63+
with:
64+
repository: leibniz-psychology/FEARBASE-R-gitops
65+
ref: main
66+
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
67+
persist-credentials: true
68+
# path: config
69+
70+
- name: Setup Kustomize
71+
uses: imranismail/setup-kustomize@v1
72+
with:
73+
kustomize-version: "3.6.1"
74+
75+
- name: Switch out image tag
76+
run: |
77+
cd stg
78+
kustomize edit set image crzpiddev.azurecr.io/${{ env.APP }}:${{ github.sha }}
79+
cat kustomization.yaml
80+
81+
- name: Commit files
82+
run: |
83+
git config --local user.email "action@github.com"
84+
git config --local user.name "GitHub Action"
85+
git commit -am "Update docker tag "${{ github.sha }}""
86+
- name: Git push
87+
uses: ad-m/github-push-action@master
88+
with:
89+
repository: leibniz-psychology/FEARBASE-R-gitops
90+
ssh: true
91+
branch: main

.github/workflows/manifests/main/opencpu/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN cd /home/opencpu && \
1010
apt-get update && \
1111
apt-get install -y openssl && \
1212
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
13-
-keyout fearbase-ocpu_ssl.key -out fearbase-ocpu_ssl.crt -subj "/CN=fearbase-ocpu.dev.zpid.org" \
13+
-keyout fearbase-ocpu_ssl.key -out fearbase-ocpu_ssl.crt -subj "/CN=fearbase-ocpu.zpid.org" \
1414
-addext "subjectAltName=DNS:fearbase-ocpu.zpid.org,DNS:www.fearbase-ocpu.zpid.org,IP:127.0.0.1"
1515

1616
RUN cd /home/opencpu && \
@@ -19,14 +19,12 @@ RUN cd /home/opencpu && \
1919

2020
#copy some config files
2121
COPY . /home/opencpu/fearbase
22-
COPY .github/workflows/manifests/main/opencpu/index.html /var/www/html/index.html
2322

2423
RUN cd /home/opencpu && \
2524
R -e "install.packages('remotes')" && \
2625
R CMD build fearbase && \
2726
mv fearbase_*.tar.gz fearbase_latest.tar.gz && \
28-
R CMD INSTALL fearbase_latest.tar.gz --library=/usr/local/lib/R/site-library && \
29-
chmod 755 /var/www/html/index.html
27+
R CMD INSTALL fearbase_latest.tar.gz --library=/usr/local/lib/R/site-library
3028

3129
# Set opencpu password
3230
RUN \
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM crzpiddev.azurecr.io/fearbase/ocpu-base-image:latest-dev
2+
3+
ARG OCPU_PASS
4+
ARG SSL_KEY
5+
6+
RUN apt update -y &&\
7+
apt install -y vim
8+
9+
RUN cd /home/opencpu && \
10+
apt-get update && \
11+
apt-get install -y openssl && \
12+
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
13+
-keyout fearbase-ocpu_ssl.key -out fearbase-ocpu_ssl.crt -subj "/CN=fearbase-ocpu.stg.zpid.org" \
14+
-addext "subjectAltName=DNS:fearbase-ocpu.stg.zpid.org,DNS:www.fearbase-ocpu.stg.zpid.org,IP:127.0.0.1"
15+
16+
RUN cd /home/opencpu && \
17+
mv /home/opencpu/fearbase-ocpu_ssl.crt /etc/ssl/certs/ && \
18+
mv /home/opencpu/fearbase-ocpu_ssl.key /etc/ssl/private/
19+
20+
#copy some config files
21+
COPY . /home/opencpu/fearbase
22+
23+
RUN cd /home/opencpu && \
24+
R -e "install.packages('remotes')" && \
25+
R CMD build fearbase && \
26+
mv fearbase_*.tar.gz fearbase_latest.tar.gz && \
27+
R CMD INSTALL fearbase_latest.tar.gz --library=/usr/local/lib/R/site-library
28+
29+
# Set opencpu password
30+
RUN \
31+
echo "opencpu:"$OCPU_PASS | chpasswd
32+
33+
34+
35+
36+
37+

0 commit comments

Comments
 (0)