-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from OpenIPC/master
New packaging and release
- Loading branch information
Showing
9 changed files
with
121 additions
and
414 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Package and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- stable | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
APP_NAME: "improver" | ||
VERSION: ${{ github.run_id }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Package source code | ||
run: | | ||
ARCHIVE_NAME="${APP_NAME}_source_${VERSION}.tar.gz" | ||
echo "Packaging source code into ${ARCHIVE_NAME}..." | ||
tar czvf $ARCHIVE_NAME \ | ||
app/ \ | ||
requirements.txt \ | ||
gunicorn_config.py \ | ||
run.sh \ | ||
update_nginx.sh \ | ||
improver.service \ | ||
config/ | ||
- name: List packaged files | ||
run: ls -lh *.tar.gz | ||
|
||
- name: Create GitHub Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: "release-${VERSION}" | ||
release_name: "Improver Release ${VERSION}" | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: "${APP_NAME}_source_${VERSION}.tar.gz" | ||
asset_name: "${APP_NAME}_source_${VERSION}.tar.gz" | ||
asset_content_type: application/gzip |
This file was deleted.
Oops, something went wrong.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Define variables for image and container names | ||
IMAGE_NAME := py-config-gs | ||
CONTAINER_NAME := py-config-gs | ||
DOCKER_COMPOSE_FILE := docker-compose.yaml | ||
PORT := 8080 # The port on the host to access Nginx | ||
|
||
# Target to build the Docker image using Docker Compose | ||
build: | ||
@echo "Building Docker images with Docker Compose..." | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) build | ||
|
||
# Target to run the Docker containers in the foreground | ||
run: build | ||
@echo "Starting Docker containers..." | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) up | ||
|
||
# Target to run Docker containers in detached mode (background) | ||
run-detached: build | ||
@echo "Starting Docker containers in detached mode..." | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) up -d | ||
|
||
# Target to stop the Docker containers | ||
stop: | ||
@echo "Stopping Docker containers..." | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) down | ||
|
||
# Target to view logs from all services | ||
logs: | ||
@echo "Showing logs from all Docker services..." | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) logs -f | ||
|
||
# Target to clean up all images and containers | ||
clean: | ||
@echo "Removing Docker images and containers..." | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) down --rmi all --volumes --remove-orphans | ||
|
||
# Help target to show available commands | ||
help: | ||
@echo "Available commands:" | ||
@echo " make build - Build the Docker images with Docker Compose" | ||
@echo " make run - Run the Docker containers in the foreground" | ||
@echo " make run-detached - Run the Docker containers in detached mode" | ||
@echo " make stop - Stop the running Docker containers" | ||
@echo " make logs - View logs for all services" | ||
@echo " make clean - Remove all containers, images, and volumes" | ||
@echo " make help - Show this help message" |
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,8 +21,6 @@ echo "Creating necessary directories..." | |
sudo mkdir -p "$DEST_DIR" | ||
sudo mkdir -p "$SCRIPTS_DIR" | ||
sudo mkdir -p "$LOG_DIR" | ||
sudo chown -R www-data:www-data "$LOG_DIR" | ||
sudo chmod -R 755 "$LOG_DIR" | ||
|
||
# Step 2: Install required packages | ||
echo "Installing gunicorn..." | ||
|
@@ -70,11 +68,7 @@ sed -i "/^}/i \\ | |
add_header Cache-Control \"public, max-age=2592000\";\\ | ||
}\\ | ||
\\n\\ | ||
# Custom error page for server errors\\ | ||
error_page 500 502 503 504 /50x.html;\\ | ||
location = /50x.html {\\ | ||
root /usr/share/nginx/html;\\ | ||
}" "$NGINX_CONFIG" | ||
" "$NGINX_CONFIG" | ||
|
||
# Test Nginx configuration | ||
echo "Testing Nginx configuration..." | ||
|
@@ -91,19 +85,26 @@ else | |
fi | ||
|
||
# Step 5: Add sudo permissions for www-data user | ||
echo "Adding sudo permissions for www-data..." | ||
if ! sudo grep -q "www-data.*systemctl" "$SUDOERS_FILE"; then | ||
echo "Adding sudo permissions for www-data..." | ||
echo "www-data ALL=(ALL) NOPASSWD: /bin/systemctl restart /etc/systemd/system/wifibroadcast.service.wants/[email protected] /bin/systemctl restart openipc, /bin/systemctl stop openipc, /bin/systemctl start openipc" | sudo tee -a "$SUDOERS_FILE" | ||
echo "www-data ALL=(ALL) NOPASSWD: /bin/systemctl restart wifibroadcast.service, /bin/systemctl restart openipc, /bin/systemctl stop openipc, /bin/systemctl start openipc" | sudo tee -a "$SUDOERS_FILE" | ||
else | ||
echo "www-data already has necessary sudo permissions." | ||
fi | ||
|
||
# Step 6: Verify the deployment | ||
echo "Verifying the deployment..." | ||
if [ -f "$DEST_DIR/run.sh" ]; then | ||
echo "Run script found. You can start the application with:" | ||
echo "sudo $DEST_DIR/run.sh" | ||
else | ||
echo "Run script not found. Please check the extracted files." | ||
fi | ||
|
||
echo "chnging perms on $LOG_DIR" | ||
sudo chown -R www-data:www-data "$LOG_DIR" | ||
sudo chmod -R 755 "$LOG_DIR" | ||
|
||
|
||
echo "Deployment completed successfully." |
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.
Oops, something went wrong.