Skip to content

Commit

Permalink
made docker-compose.yml configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Oaphi committed Jan 7, 2025
1 parent b6321ca commit b5e0fe8
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 9 deletions.
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@

# Docker environment (production)
docker/env
# mount mysql volume so that its easy to interact with the database outside of the container.
# This also allows persistent database storage
docker/mysql
# allow custom docker-compose files as users might have different needs
docker-compose*.yml
!docker-compose.yml

# Don't track changes to the docker-compose .env file only in project root
/.env

# mount mysql volume so that its easy to interact with the database outside of the container. This also allows persistent database storage
docker/mysql

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
Expand Down
11 changes: 6 additions & 5 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Docker Installation

A [docker-compose.yml](../docker-compose.yml) file is provided for deployment with Docker compose, if you choose.
A [docker-compose.example.yml](./docker-compose.example.yml) file is provided for deployment with Docker Compose. To use it, either copy it to project root as docker-compose.yml, or it will be automatically created from the example file when you run the [local-setup.sh](./local-setup.sh) script.

To use docker compose, you need to install the docker-compose-plugin. You can check whether it is already installed by running the following command.
To use Docker Compose, you need to install the docker-compose-plugin.
You can check if it's already installed via the following command:

```bash
sudo docker compose version
```

If your version is 2.x or higher, then you are good. Otherwise, you should install the docker compose plugin. For a system like debian or ubuntu, you can use the following command.
If the version is 2.x or higher, you are all set. If not, you should install the plugin. On a Debian-based Linux distro, you can run the following:

```bash
sudo apt-get install docker-compose-plugin
```

For Mac OS, you can install docker desktop by downloading it from the docker website. After starting the application, the docker compose command becomes available in your terminal.
For Mac OS, you can install Docker Desktop by downloading it from the Docker website. After starting the application, the docker compose command becomes available in your terminal.

Depending on your setup, you may need to prefix every docker command with sudo.

Expand Down Expand Up @@ -71,7 +72,7 @@ NOTE: If you get an error like "Cannot connect to the Docker daemon at ...", you
Then start your containers:

```bash
docker compose up # append -d (--detach) if you want, although it can be useful to see output in the terminal
docker compose up # append -d (--detach) if you don't want to see output in the terminal
```

After about 20 seconds, check to make sure the server is running (and verify port 3000, note that you can change this mapping in the `.env` file)
Expand Down
1 change: 1 addition & 0 deletions docker/compose-env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
COMPOSE_FILE=./docker-compose.yml
LOCAL_DEV_PORT=3000
COMMUNITY_NAME=Dev Community
MAILER_PROTOCOL=https
Expand Down
54 changes: 54 additions & 0 deletions docker/docker-compose.example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
services:
db:
restart: on-failure:3
build:
context: "."
dockerfile: docker/Dockerfile.db
volumes:
- ./docker/mysql:/var/lib/mysql
env_file:
- ${ENV_FILE_LOCATION}
command: mysqld --mysql-native-password=on --skip-mysqlx
cap_add:
- SYS_NICE
healthcheck:
test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
start_period: 5s
interval: 5s
timeout: 5s
retries: 12


uwsgi:
restart: on-failure:3
build:
context: "."
dockerfile: ${CLIENT_DOCKERFILE}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
environment:
- COMMUNITY_NAME=${COMMUNITY_NAME}
- RAILS_ENV=${RAILS_ENV}
- MAILER_PROTOCOL=${MAILER_PROTOCOL}
- CONFIRMABLE_ALLOWED_ACCESS_DAYS=${CONFIRMABLE_ALLOWED_ACCESS_DAYS}
- LOCAL_DEV_PORT=${LOCAL_DEV_PORT}
env_file:
- ${ENV_FILE_LOCATION}
ports:
- "${LOCAL_DEV_PORT}:3000"
volumes:
- .:/code
- ./static:/var/www/static
- ./images:/var/www/images
links:
- redis
- db

redis:
restart: on-failure:3
image: redis:latest
healthcheck:
test: ["CMD", "redis-cli","ping"]
2 changes: 1 addition & 1 deletion docker/local-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ cp ./docker/dummy.env ./docker/env
cp ./docker/compose-env .env
cp config/database.docker.yml config/database.yml
cp config/storage.docker.yml config/storage.yml
cp ./.sample.irbrc ./.irbrc
cp ./.sample.irbrc ./.irbrc

0 comments on commit b5e0fe8

Please sign in to comment.