Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker compose #748

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ our [website](https://chaoss.github.io/grimoirelab/).

### Quickstart

It is recommended to use [docker compose](https://docs.docker.com/compose/install/linux/) to create your SortingHat environment, but you can create it with docker commands too.

#### Docker compose (recommended)

To run a standalone SortingHat instance, you need git and docker compose to run the following commands:

```
git clone [email protected]:chaoss/grimoirelab-sortinghat.git
cd grimoirelab-sortinghat/docker
docker compose up
```

Then go to [localhost:8000](http://localhost:8000) and login with username and password `admin`.

#### Docker

These commands will start a SortingHat server container in developer mode
with a MySQL and Redis server containers. The service will run on an HTTP
server on `localhost:8000`. You can access it with credentials `admin:admin`.
Expand Down
86 changes: 86 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
version: '2.2'

services:
mariadb:
image: mariadb:10.6
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
healthcheck:
test: [ "CMD", "/usr/local/bin/healthcheck.sh", "--su=root", "--connect", "--innodb_initialized" ]
retries: 5
volumes:
- mariadb_db:/var/lib/mysql


redis:
image: redis:latest
ports:
- "6379:6379"
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
retries: 5

sortinghat:
restart: on-failure:3
image: grimoirelab/sortinghat
environment:
- SORTINGHAT_SECRET_KEY=secret
- SORTINGHAT_DB_HOST=mariadb
- SORTINGHAT_DB_PORT=3306
- SORTINGHAT_DB_DATABASE=sortinghat_test
- SORTINGHAT_DB_USER=root
- SORTINGHAT_DB_PASSWORD=
- SORTINGHAT_REDIS_HOST=redis
- SORTINGHAT_REDIS_PASSWORD=
- SORTINGHAT_SUPERUSER_USERNAME=admin
- SORTINGHAT_SUPERUSER_PASSWORD=admin
- SORTINGHAT_ALLOWED_HOST=sortinghat,nginx,localhost,127.0.0.1,[::1]
- SORTINGHAT_CORS_ALLOWED_ORIGINS=http://localhost:8000,http://127.0.0.1:8000
expose:
- "9314"
volumes:
- sortinghat-static:/opt/venv/lib/python3.9/site-packages/sortinghat/static/
depends_on:
mariadb:
condition: service_healthy
redis:
condition: service_healthy

sortinghat_worker:
image: grimoirelab/sortinghat-worker
environment:
- SORTINGHAT_SECRET_KEY=secret
- SORTINGHAT_DB_HOST=mariadb
- SORTINGHAT_DB_PORT=3306
- SORTINGHAT_DB_DATABASE=sortinghat_test
- SORTINGHAT_DB_USER=root
- SORTINGHAT_DB_PASSWORD=
- SORTINGHAT_REDIS_HOST=redis
- SORTINGHAT_REDIS_PASSWORD=
depends_on:
mariadb:
condition: service_healthy
redis:
condition: service_healthy

nginx:
restart: on-failure:3
image: nginx:latest
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
- ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
- sortinghat-static:/sortinghat:ro
ports:
- "8000:8000"
depends_on:
- sortinghat
healthcheck:
test: "curl -s --head http://localhost:8000/identities/api/ | grep Set-Cookie || exit 1"
retries: 5

volumes:
sortinghat-static:
mariadb_db:
35 changes: 35 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
upstream sortinghat {
server sortinghat:9314;
}
server {
include mime.types;
sendfile on;
listen 8000;

server_name localhost nginx;

location / {
return 302 /identities;
}

location /identities {
rewrite ^/identities/(.*) /$1 break;
sub_filter </head>
'<script defer data-domain="bitergia.gitlab.io" src="https://plausible.io/js/plausible.js"></script></head>';
sub_filter_once on;

include /etc/nginx/uwsgi_params;
uwsgi_pass sortinghat;
uwsgi_param Host $host;
uwsgi_param X-Real-IP $remote_addr;
uwsgi_param X-Forwarded-For $proxy_add_x_forwarded_for;
uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto;
}

location ~ ^/identities/(css|js|fonts)/ {
rewrite ^/identities/(.*) /$1 break;

root /sortinghat;
}
}

13 changes: 13 additions & 0 deletions docker/nginx/uwsgi_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;