Skip to content

Commit

Permalink
start creation of infra and github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Mar 12, 2024
1 parent 4d2b3b7 commit d581829
Show file tree
Hide file tree
Showing 17 changed files with 187 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ CHECKIN_LANES='{"LANE1":"__PLACE_YOUR_LANE1_UUID__",
"LANE3":"__PLACE_YOUR_LANE3_UUID__",
"LANE4":"__PLACE_YOUR_LANE4_UUID__"}'

LANE2PORT={"LANE1":"__PORT__",
LANE2PORT='{"LANE1":"__PORT__",
"LANE2":"__PORT__",
"LANE3":"__PORT__"}
"LANE3":"__PORT__"}'

ADMIN_USERNAME=__ADMIN_USERNAME__
ADMIN_PASSWORD=__ADMIN_PLAINTEXT_PASSWORD__
85 changes: 85 additions & 0 deletions .github/workflows/mian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI/CD

on:
push:
pull_request:

env:
PROJECT_NAME: sfscon-backend
DOCKER_IMAGE: ghcr.io/${{ github.repository }}/sfscon-backend

jobs:
deploy-test:
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/main'
concurrency: deploy-test
env:
SERVER_PORT: 1005
DOCKER_TAG: ${{ github.sha }}-test
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Create .env file
uses: noi-techpark/github-actions/env-file@v2
with:
working-directory: ${{ env.WORKING_DIRECTORY }}
env:
X_SERVER_PORT: ${{ env.SERVER_PORT }}
X_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE }}
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}

- name: Build and push images
uses: noi-techpark/github-actions/docker-build-and-push@v2
with:
working-directory: infrastructure
docker-username: ${{ github.actor }}
docker-password: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy application
uses: noi-techpark/github-actions/docker-deploy@v2
with:
working-directory: infrastructure/ansible
hosts: "test"
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
docker-username: "noi-techpark-bot"
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
project-name: ${{ env.PROJECT_NAME }}

deploy-prod:
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/prod'
# needs: test
concurrency: deploy-prod
env:
SERVER_PORT: 1006
DOCKER_TAG: ${{ github.sha }}
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Create .env file
uses: noi-techpark/github-actions/env-file@v2
with:
working-directory: ${{ env.WORKING_DIRECTORY }}
env:
X_SERVER_PORT: ${{ env.SERVER_PORT }}
X_DOCKER_IMAGE: ${{ env.DOCKER_IMAGE }}
X_DOCKER_TAG: ${{ env.DOCKER_TAG }}

- name: Build and push images
uses: noi-techpark/github-actions/docker-build-and-push@v2
with:
working-directory: infrastructure
docker-username: ${{ github.actor }}
docker-password: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy application
uses: noi-techpark/github-actions/docker-deploy@v2
with:
working-directory: infrastructure/ansible
hosts: "test"
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
docker-username: "noi-techpark-bot"
docker-password: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
project-name: ${{ env.PROJECT_NAME }}
12 changes: 12 additions & 0 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: REUSE Compliance Check

on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v3
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Upstream-Name: OpenCON
Upstream-Contact: DigitalCUBE <info@digitalcube.rs>
Source: https://m.opencon.dev/

Files: .gitignore *.sample .env.sample docker-compose.yaml src/*.py src/*.yaml src/*.xml src/docker/* README.md requirements.txt src/pyproject.toml src/tests/assets/fake_attendees.json src/tests/pytest.ini
Files: .gitignore *.sample .env.sample docker-compose.yaml src/*.py src/*.yaml src/*.xml infrastructure/docker/* README.md requirements.txt src/pyproject.toml src/tests/assets/fake_attendees.json src/tests/pytest.ini
Copyright: 2023 DigitalCUBE <info@digitalcube.rs>
License: GPL-3.0-or-later

7 changes: 3 additions & 4 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
services:

redis:

command: redis-server
hostname: redis
image: redis:alpine
Expand All @@ -11,7 +10,7 @@ services:
conferences:
build:
context: .
dockerfile: src/docker/Dockerfile.conferences
dockerfile: ../infrastructure/docker/Dockerfile.conferences
command: uvicorn main:app --host 0.0.0.0 --reload # sleep 9999999999
depends_on:
- redis
Expand All @@ -28,7 +27,7 @@ services:
telegram:
build:
context: .
dockerfile: src/docker/Dockerfile.telegram
dockerfile: ../infrastructure/docker/Dockerfile.telegram

command: python workers/telegram.py # sleep 99999
depends_on:
Expand All @@ -45,7 +44,7 @@ services:
push_notifications:
build:
context: .
dockerfile: src/docker/Dockerfile.push_notifications
dockerfile: ../infrastructure/docker/Dockerfile.push_notifications

command: python workers/push_notifications.py # sleep 99999
depends_on:
Expand Down
4 changes: 4 additions & 0 deletions infrastructure/ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[defaults]
inventory = ./hosts
roles_path = ./roles
retry_files_enabled = False
19 changes: 19 additions & 0 deletions infrastructure/ansible/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- hosts: all
vars:
ansible_python_interpreter: /usr/bin/python3
tasks:
- name: Login to GitHub Container Registry
ansible.builtin.shell:
cmd: echo "{{ docker_password }}" | docker login "{{ docker_host }}" --username "{{ docker_username }}" --password-stdin
- name: Execute Docker deployment
ansible.builtin.include_role:
name: ansible-docker-deployment
vars:
docker_deployment_project_name: '{{ project_name }}'
docker_deployment_release_name: '{{ release_name }}'
docker_deployment_release_files:
- local: ../docker-compose.run.yml
remote: docker-compose.yml
- local: ../../.env
remote: .env
5 changes: 5 additions & 0 deletions infrastructure/ansible/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[test]
docker03.testingmachine.eu ansible_user='noi-techpark-bot' ansible_ssh_common_args='-o StrictHostKeyChecking=no'

[prod]
docker03.opendatahub.com ansible_user='noi-techpark-bot' ansible_ssh_common_args='-o StrictHostKeyChecking=no'
2 changes: 2 additions & 0 deletions infrastructure/ansible/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- src: git+https://github.com/noi-techpark/ansible-docker-deployment.git
version: "2.0"
2 changes: 2 additions & 0 deletions infrastructure/ansible/roles/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
8 changes: 8 additions & 0 deletions infrastructure/docker-compose.build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.4"

services:
app:
image: ${DOCKER_IMAGE}:${DOCKER_TAG}
build:
context: ../
dockerfile: infrastructure/docker/dockerfile-static-nginx
8 changes: 8 additions & 0 deletions infrastructure/docker-compose.run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3.4"

services:
app:
image: ${DOCKER_IMAGE}:${DOCKER_TAG}
restart: unless-stopped
ports:
- ${SERVER_PORT}:80
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions infrastructure/docker/dockerfile-static-nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM nginx:1.23.4-alpine-slim

COPY ./databrowser/dist /usr/share/nginx/html
COPY ./infrastructure/nginx/default.conf /etc/nginx/conf.d/default.conf
32 changes: 32 additions & 0 deletions infrastructure/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
server {
listen 80;
listen [::]:80;
server_name localhost;

include mime.types;
types {
font/ttf ttf;
}

access_log off;

gzip on;
gzip_types text/html application/javascript application/json text/css font/ttf application/x-font-ttf;

root /usr/share/nginx/html;
index index.html index.htm;

location / {
try_files $uri $uri/ $uri.html /index.html;
}

location ~* \.(?:css|js|jpg|svg|ttf)$ {
expires 30d;
add_header Cache-Control "public";
}

location ~* \.(?:json)$ {
expires 1d;
add_header Cache-Control "public";
}
}

0 comments on commit d581829

Please sign in to comment.