From 8e8d0cee9e139d093819e8a40d3713b95e805963 Mon Sep 17 00:00:00 2001 From: Jayden Pyles Date: Wed, 26 Jun 2024 16:31:53 -0500 Subject: [PATCH] wip: deployment guide --- Makefile | 4 ++-- README.md | 32 ++++++++++++++++++++++++++++++-- ansible/config.yaml | 2 +- docker-compose.yml | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2b8670a..26383d2 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,8 @@ COMPOSE_DEV = docker compose -f docker-compose.yml -f docker-compose.dev.yml COMPOSE_PROD = docker compose -f docker-compose.yml -HOSTNAME_PROD = ... -HOSTNAME_DEV = localhost +HOSTNAME_PROD = "localhost" +HOSTNAME_DEV = "localhost" .PHONY: help deps build pull up-prod up-dev down setup deploy diff --git a/README.md b/README.md index 9fba5b6..23f13af 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Template designed to quickly build full stack apps. +Utilizes Github Actions and Ansible to build Docker images to quickly deploy onto an AWS EC2 Debian instance. + ## Technologies - Containerization: Docker/Docker Compose @@ -12,17 +14,43 @@ Template designed to quickly build full stack apps. - Frameworks/Libraries: PDM, TailwindCSS +## Prerequisites + +- Install Ansible + +- Create a Dockerhub account/repo and fill out the Github repo environmental variables: + + - DOCKERHUB_TOKEN + - DOCKERHUB_USERNAME + - DOCKERHUB_REPO + +- Complete the `config.yaml` and the `inventory.yaml` in the `ansible` directory + + - `github_repo`: Github repo clone address + - `deploy_path`: Path where to clone the repo to on the server + - `deploy_command`: `Make` command to run to deploy on the server + ## Deployment +### Local Deployment + Uses `make` to quickly dispatch `docker-compose` commands. - `deps`: rebuilds the frontend to deploy statically using the api - `build`: builds the container using `docker-compose build ` -- `up-dev`: ups the container using `docker-compose -f docker-compose.yml up` +- `up-prd`: ups the container using `docker-compose -f docker-compose.yml up` -- `up-prd`: ups the container using `docker-compose -f docker-compose.yml -f docker-compose.dev.yml up` +- `up-dev`: ups the container using `docker-compose -f docker-compose.yml -f docker-compose.dev.yml up` which will deploy with local volumes. Ex: `make deps build up-dev` + +### Server Deployment + +Easy deployment using `make setup deploy` after completing the required config files. + +- `setup`: Install dependencies and clone repo onto server + +- `deploy`: Deploy on server diff --git a/ansible/config.yaml b/ansible/config.yaml index 1db920a..7b99cca 100644 --- a/ansible/config.yaml +++ b/ansible/config.yaml @@ -1,3 +1,3 @@ github_repo: https://github.com/jaypyles/webapp-template.git -deploy_path: /home/admin/website +deploy_path: /home/admin/site deploy_command: make pull up-prd diff --git a/docker-compose.yml b/docker-compose.yml index d399720..a6c01cf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ version: "3" services: frontend: + image: jpyles0524/webapp-template:latest build: context: ./ container_name: frontend