Skip to content

Commit

Permalink
sync changes with other repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilorv committed Mar 30, 2025
1 parent 01608db commit bcf84ed
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy to TDT4242 server development

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
deploy:
runs-on: self-hosted
env:
REPO_NAME: ${{ github.event.repository.name }}
COMPOSE_FILE: "docker-compose.yml"

steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Dotenv Action
uses: falti/dotenv-action@v1.1.4
with:
export-variables: true
keys-case: bypass

- name: Check status of config file
run: |
env
docker compose version
cd $GITHUB_WORKSPACE
docker compose -f $COMPOSE_FILE --verbose config && printf "OK\n" || exit 1
- name: Build and run docker image
run: docker compose -f $COMPOSE_FILE up --force-recreate --build -d

- name: Verify that gateway is available
run: docker ps
11 changes: 6 additions & 5 deletions .github/workflows/update_primary_nginx.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: UNFINISHED - setup nginx from the configuration file
name: Setup nginx from the configuration file

on:
workflow_dispatch:
Expand All @@ -19,16 +19,17 @@ jobs:
- name: Check environment variables
run: env

#Doesn't work properly, envsubst replaces all instances of $variable and ${variable}, but we want to keep e.g., $host as nginx variables
- name: Create temporary nginx config file
run: envsubst '$http_host, $remote_addr, $proxy_add_x_forwarded_for' < ./nginx_template.txt > temp_default.conf
# Maybe look at https://www.baeldung.com/linux/envsubst-command to get an idea
run: envsubst '${DEV_PORT_PREFIX}, ${STAG_PORT_PREFIX}, ${PROD_PORT_PREFIX}, ${GATEWAY_POSTFIX},' < ./nginx_template.txt > temp_default.conf

- name: user of runner
run: whoami

- name: Copy temporary file to correct place
run: cp temp_default.conf /etc/nginx/conf.d/nginx_securefit.conf
run: sudo cp temp_default.conf /etc/nginx/conf.d/nginx_securefit.conf

- name: Show nginx file
run: cat /etc/nginx/conf.d/nginx_securefit.conf

- name: Restart NGINX
run: sudo systemctl reload nginx
12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ services:
build:
context: backend/
dockerfile: Dockerfile
network: host #Need to expose it during setup, then it is isolated during running
network: host
networks:
backend_bridge:
ports:
- ${PROD_PORT_PREFIX}4:8000
volumes:
- backend_vol:/app

Expand All @@ -21,9 +23,11 @@ services:
build:
context: frontend/
dockerfile: Dockerfile
network: host #Need to expose it during setup, then it is isolated during running
#environment:
# PUBLIC_URL: "http://tdt4242-${GROUP_ID}.idi.ntnu.no/prod/public"
network: host
environment:
PUBLIC_URL: "http://tdt4242-${GROUP_ID}.idi.ntnu.no/prod/public"
ports:
- ${PROD_PORT_PREFIX}5:3000
networks:
backend_bridge:

Expand Down

0 comments on commit bcf84ed

Please sign in to comment.