Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #298 from bookbrainz/api-docker
Deployment Docker setup for test API
- Loading branch information
Showing
19 changed files
with
262 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
if [[ ! -d "src" ]]; then | ||
echo "This script must be run from the top level directory of the bookbrainz-site source." | ||
exit -1 | ||
fi | ||
|
||
docker-compose -f docker-compose.api.yml run --rm startup && | ||
docker-compose -f docker-compose.api.yml up --build bookbrainz-api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
version: '3.4' | ||
|
||
services: | ||
|
||
bookbrainz-api: | ||
container_name: bookbrainz-api | ||
command: npm run start-api | ||
build: | ||
context: ./ | ||
dockerfile: Dockerfile | ||
target: bookbrainz-dev | ||
restart: unless-stopped | ||
ports: | ||
- "9098:9098" | ||
depends_on: | ||
# - elasticsearch | ||
- redis | ||
- postgres | ||
volumes: | ||
- "./config/config.json:/home/bookbrainz/bookbrainz-site/config/config.json:ro" | ||
|
||
postgres: | ||
container_name: postgres | ||
restart: unless-stopped | ||
image: postgres:9.5 | ||
user: postgres | ||
ports: | ||
- "5432:5432" | ||
environment: | ||
- POSTGRES_USER=postgres | ||
volumes: | ||
- postgres-data:/var/lib/postgresql/data | ||
|
||
# elasticsearch: | ||
# container_name: elasticsearch | ||
# restart: unless-stopped | ||
# image: docker.elastic.co/elasticsearch/elasticsearch:5.6.8 | ||
# environment: | ||
# # Skip bootstrap checks (see https://github.com/docker-library/elasticsearch/issues/98) | ||
# - transport.host=127.0.0.1 | ||
# - discovery.zen.minimum_master_nodes=1 | ||
# ports: | ||
# - "9200:9200" | ||
# volumes: | ||
# - elasticsearch-data:/usr/share/elasticsearch/data | ||
|
||
redis: | ||
container_name: redis | ||
restart: unless-stopped | ||
image: redis:3.2-alpine | ||
command: "redis-server --appendonly yes" | ||
ports: | ||
- "6379:6379" | ||
- "3600:3600" | ||
|
||
startup: | ||
image: waisbrot/wait | ||
container_name: startup | ||
restart: "no" | ||
environment: | ||
- TARGETS=redis:6379,postgres:5432 #,elasticsearch:9200 | ||
- TIMEOUT=60 | ||
depends_on: | ||
# - elasticsearch | ||
- redis | ||
- postgres | ||
|
||
volumes: | ||
postgres-data: | ||
# elasticsearch-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
# | ||
# Build webservice images from the currently checked out version of BookBrainz | ||
# and push it to the Docker Hub, with an optional tag (by default "beta"). | ||
# | ||
# Usage: | ||
# $ ./push-webservice.sh [env] [tag] | ||
# | ||
# Examples: | ||
# $ ./push-webservice.sh beta beta # will push image with tag beta and deploy environment beta | ||
# $ ./push-webservice.sh prod v-2018-07-14.0 # will push images with tag v-2018-07-14.0 and deploy env prod | ||
|
||
cd "$(dirname "${BASH_SOURCE[0]}")/../" | ||
|
||
git describe --tags --dirty --always > .git-version | ||
|
||
ENV=${1:-beta} | ||
TAG=${2:-beta} | ||
|
||
echo "Building BookBrainz image with env $ENV tag $TAG and docker build target bookbrainz-webservice" | ||
docker build -t metabrainz/bookbrainz-webservice:$TAG \ | ||
--target bookbrainz-webservice \ | ||
--build-arg GIT_COMMIT_SHA=$(git rev-parse HEAD) \ | ||
--build-arg DEPLOY_ENV=webservice-$ENV . | ||
RESULT=$? | ||
if [ $RESULT -eq 0 ]; then | ||
echo "Done!" | ||
else | ||
echo "Docker build command failed with error code $RESULT, exiting." | ||
exit 1; | ||
fi | ||
|
||
echo "Pushing image to docker hub metabrainz/bookbrainz-webservice:$TAG..." | ||
docker push metabrainz/bookbrainz-webservice:$TAG | ||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# BookBrainz rc.local | ||
# Enables a specific runit service depending on what the | ||
# CONTAINER_NAME variable is set to | ||
|
||
|
||
if [ "${CONTAINER_NAME}" = "bookbrainz-webservice-test" ] | ||
then | ||
rm -f /etc/service/webserver/down | ||
exit 0 | ||
fi | ||
|
||
echo "init script has no clue which service to start. Set env var CONTAINER_NAME" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
pushd /home/bookbrainz/bookbrainz-site | ||
exec node ./lib/api/app.js | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
exec run-consul-template -config /etc/consul-template-webserver.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.