From 9cdab300c00d8189c3d26b53cfe442a8d819ad2e Mon Sep 17 00:00:00 2001 From: xyTom <75466119+xyTom@users.noreply.github.com> Date: Tue, 7 Nov 2023 07:15:53 +0000 Subject: [PATCH 1/2] Provide local deploy instructions --- README.md | 42 ++++++++++++++++++++++++++++++++++++++ docker-compose.local.yml | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 docker-compose.local.yml diff --git a/README.md b/README.md index 5f7644ec..e921bb55 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,45 @@ bundle install yarn install rake ``` + +## Local Deployment with Docker Compose + +### Start the Server + +```sh +git clone https://github.com/Proj-IDEALS/ideals.git +cd ideals +docker-compose -f docker-compose.local.yml up --build +``` + +### Create the Database + +```sh +docker-compose -f docker-compose.local.yml exec db psql -U postgres -c "CREATE DATABASE ideals;" +``` + +### Import the Backup Data + +```sh +docker-compose -f docker-compose.prod.yml exec db psql -U postgres -d ideals -f backups/dump_19-04-2023_06_36_25.sql +``` + +### Some Useful Command for troubleshoot + +To see all the docker container +```sh +docker ps -all +``` + +To remove one docker container (It is useful when you having issues to start the server, try to remove the old containers and run start server command again) +```sh +docker rm ideals_app_1 +``` + +### To backup the data + +```sh +docker-compose -f docker-compose.prod.yml exec db pg_dump -U postgres -d ideals > backups/backup.sql +``` + +⚠️ Remember to run backup command from time to time \ No newline at end of file diff --git a/docker-compose.local.yml b/docker-compose.local.yml new file mode 100644 index 00000000..ea7b77e4 --- /dev/null +++ b/docker-compose.local.yml @@ -0,0 +1,44 @@ +version: "3.9" + +services: + db: + image: postgres:14.1-alpine + restart: always + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=postgres + ports: + - '5432:5432' + volumes: + - db:/var/lib/postgresql/data + - ./backups:/backups + app: + image: isurangaperera/ideals:latest + environment: + - RAILS_ENV=production + - RAILS_SERVE_STATIC_FILES=true + - RAILS_LOG_TO_STDOUT=true + command: bundle exec rails server -b 0.0.0.0 + ports: + - '3000:3000' + depends_on: + - db + links: + - db + restart: always + # nginx: + # build: + # context: ./proxy + # links: + # - app + # stdin_open: true + # tty: true + # ports: + # - '80:80' + # - '443:443' + # volumes: + # - /home/ubuntu/certs/:/etc/nginx/ssl/:ro + # restart: always +volumes: + db: + driver: local From 2bcdc6dedaac85a726a2202f14f1c36c22c85c0e Mon Sep 17 00:00:00 2001 From: xyTom <75466119+xyTom@users.noreply.github.com> Date: Tue, 7 Nov 2023 07:45:57 +0000 Subject: [PATCH 2/2] Update docker compose to fix into different cpu arch --- docker-compose.local.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.local.yml b/docker-compose.local.yml index ea7b77e4..71f7a81d 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -13,7 +13,9 @@ services: - db:/var/lib/postgresql/data - ./backups:/backups app: - image: isurangaperera/ideals:latest + build: + context: ./app + dockerfile: prod.Dockerfile environment: - RAILS_ENV=production - RAILS_SERVE_STATIC_FILES=true