-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified workflows to install nginx not as container
- Loading branch information
Showing
6 changed files
with
26 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ env: | |
jobs: | ||
build_and_push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Checkout the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
|
@@ -38,14 +40,9 @@ jobs: | |
|
||
- name: Display content of .env file | ||
run: cat ./config/.env | ||
|
||
- name: Update Nginx configuration file | ||
run: | | ||
sed -i "s/server_name localhost/server_name ${{ secrets.DOMAIN }}/g" ./nginx/nginx.conf | ||
working-directory: . | ||
|
||
- name: Build Docker image using Docker Compose | ||
run: docker-compose -f docker-compose.dev.yml build | ||
run: docker-compose -f docker-compose.prod.yml build | ||
|
||
- name: verify that all the container have been built | ||
run: docker images | ||
|
@@ -84,11 +81,13 @@ jobs: | |
submodules: recursive | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
|
||
- name: Set ENV variables | ||
run: | | ||
echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV | ||
echo $GITHUB_ENV | ||
|
||
- name: Create project directory and conf file | ||
uses: appleboy/[email protected] | ||
with: | ||
|
@@ -113,6 +112,7 @@ jobs: | |
echo "DOMAIN=${{ secrets.DOMAIN }}" >> "/opt/${{ env.REPO_NAME }}/config/.env" | ||
cat "/opt/${{ env.REPO_NAME }}/config/.env" | ||
- name: SCP Docker Compose file and Nginx conf | ||
uses: appleboy/scp-action@master | ||
with: | ||
|
@@ -122,23 +122,6 @@ jobs: | |
source: "./docker-compose.prod.yml" | ||
target: "/opt/${{ env.REPO_NAME }}/" | ||
|
||
- name: SCP Nginx conf file | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
source: "./nginx/nginx.prod.conf" | ||
target: "/opt/${{ env.REPO_NAME }}/" | ||
|
||
- name: Update Nginx configuration file | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
sed -i "s/yourdomain.com/${{ secrets.DOMAIN }}/g" /opt/${{ env.REPO_NAME }}/nginx/nginx.prod.conf | ||
|
||
- name: Upgrade server and install Docker | ||
uses: appleboy/[email protected] | ||
|
@@ -164,7 +147,9 @@ jobs: | |
sudo apt-get update -y | ||
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose docker-compose-plugin -y | ||
sudo apt upgrade -y | ||
- name: set lower case owner name | ||
run: | | ||
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} | ||
|
@@ -192,4 +177,14 @@ jobs: | |
docker exec web python manage.py migrate | ||
docker exec web python manage.py collectstatic --noinput --clear | ||
- name: Restart Nginx Service | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
sudo systemctl restart nginx | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,38 +21,8 @@ services: | |
env_file: | ||
- ./config/.env | ||
|
||
nginx: | ||
image: nginx:latest | ||
container_name: nginx_reverse_proxy | ||
volumes: | ||
- static_volume:/home/app/web/static | ||
- media_volume:/home/app/web/media | ||
- ./nginx/nginx.prod.conf:/etc/nginx/nginx.conf:ro | ||
- certbot_volume:/etc/letsencrypt | ||
ports: | ||
- 80:80 | ||
- 443:443 | ||
restart: always | ||
depends_on: | ||
- web | ||
|
||
|
||
certbot: | ||
image: certbot/certbot | ||
container_name: certbot | ||
volumes: | ||
- certbot_volume:/etc/letsencrypt | ||
- ./config:/etc/letsencrypt/config | ||
- certbot_webroot:/var/www/certbot | ||
env_file: | ||
- ./config/.env | ||
entrypoint: /bin/sh -c "trap exit TERM; while :; do certbot certonly --webroot -w /var/www/certbot --email [email protected] --agree-tos --no-eff-email --domains h1v3.xyz; sleep 12h & wait $${!}; done;" | ||
|
||
|
||
|
||
volumes: | ||
postgres_data: | ||
static_volume: | ||
media_volume: | ||
certbot_volume: | ||
certbot_webroot: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.