Skip to content
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ To run the Docker version, follow these steps:
and open the directory in the console. Then run `git clone https://github.com/Human-Connection/Clock-of-Change-API.git` to clone the repository to this directory.
2. Go to the newly created Clock-of-Change-API directory (`cd Clock-of-Change-API` in the console)
3. Run `docker-compose up`. This will build the Docker container on first startup and run it. This can take a while, but after some time you should see the Clock of Change ticking.
4. To create an initial API key and sample entries, run `docker-compose exec db seed.sh`. The initial API key you can use with your requests will have the value `secret`.

Now the Clock of Change API server is ready for usage at [http://127.0.0.1:1337](http://127.0.0.1:1337)

Expand Down
18 changes: 13 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ version: '3'
services:
db:
image: mysql:5
volumes:
- coc_api_dbdata:/var/lib/mysql
- ./seed.sh:/usr/local/bin/seed.sh
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_ROOT_PASSWORD: clockofchangepw
MYSQL_DATABASE: clock_of_change
MYSQL_USER: coc
MYSQL_PASSWORD: 123456
ports:
- 3306:3306
- 3306:3306

mailhog:
container_name: mailhog
Expand All @@ -21,14 +26,14 @@ services:
build:
context: .
volumes:
- ".:/home/node/coc-api"
- "/home/node/coc-api/node_modules"
- .:/home/node/coc-api
- /home/node/coc-api/node_modules
ports:
- 1337:1337
environment:
- MYSQL_HOST=db
- MYSQL_DB=clock_of_change
- MYSQL_USER=root
- MYSQL_USER=coc
- MYSQL_PASS=123456
- MAIL_HOST=mailhog
- MAIL_PORT=1025
Expand All @@ -38,3 +43,6 @@ services:
- db
- mailhog
command: bash -c "wait-on tcp:db:3306 && db-migrate up && npm run start"

volumes:
coc_api_dbdata:
6 changes: 6 additions & 0 deletions seed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD $MYSQL_DATABASE << EOF
INSERT INTO \`clock_of_change\`.\`apikeys\` (\`secret\`, \`valid\`) VALUES ('secret', '1');
INSERT INTO \`clock_of_change\`.\`entries\` (\`firstname\`, \`lastname\`, \`email\`, \`country\`, \`message\`, \`confirm_key\`, \`beta\`, \`newsletter\`, \`pax\`, \`email_confirmed\`, \`status\`) VALUES ('Pamela', 'Musterfrau', 'pamela@example.org', 'US', 'Let us change the world!', 'confirm', '1', '0', '1', '1', '1');
INSERT INTO \`clock_of_change\`.\`entries\` (\`firstname\`, \`lastname\`, \`email\`, \`country\`, \`message\`, \`confirm_key\`, \`beta\`, \`newsletter\`, \`pax\`, \`email_confirmed\`, \`status\`) VALUES ('Max', 'Mustermann', 'max@example.org', 'DE', 'Lasst uns die Welt verbessern!', 'confirm', '0', '1', '1', '1', '1');
EOF