Skip to content

Commit

Permalink
Merge pull request #59 from Proj-IDEALS/add-local-deploy-instructions
Browse files Browse the repository at this point in the history
Add local deploy instructions
  • Loading branch information
xyTom authored Nov 7, 2023
2 parents 115fe0a + 2bcdc6d commit be2e039
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
46 changes: 46 additions & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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:
build:
context: ./app
dockerfile: prod.Dockerfile
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

0 comments on commit be2e039

Please sign in to comment.