Skip to content

Commit 0f12176

Browse files
committed
Split entry point to different files
1 parent 01a6b34 commit 0f12176

7 files changed

Lines changed: 69 additions & 30 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM python:3.8-slim-buster
33
# Update packages and
44
# prepare alembic for docker compose setup
55
RUN apt-get update && \
6-
apt-get install -y libpq-dev && \
6+
apt-get install -y libpq-dev jq && \
77
rm -rf /var/lib/apt/lists/* && \
88
pip3 install --no-cache-dir --upgrade pip setuptools && \
99
pip3 install --no-cache-dir psycopg2-binary alembic

configs/docker_compose_entrypoint.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

configs/docker_init_migration.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
# Running alembic migrations to head (using config file specified
6+
# by the ALEMBIC_CONFIG environment variable)
7+
if [ -z "$ALEMBIC_CONFIG" ]
8+
then
9+
echo "Please explicitly set the ALEMBIC_CONFIG environment variable to point to an alembic configuration file"
10+
exit 1
11+
fi
12+
13+
ALEMBIC_CONFIG="$ALEMBIC_CONFIG" sh alembic.sh upgrade head

configs/docker_init_moonstream.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
# Create user for Moonstream application
6+
MOONSTREAM_USER="$(brood users create \
7+
--username moonstream \
8+
--email moonstream@example.com \
9+
--password moonstream --verified | jq -r .id)"
10+
11+
# Create token for Moonstream user
12+
MOONSTREAM_TOKEN_ID="$(brood tokens create \
13+
--username moonstream | jq -r .id)"
14+
15+
# Create group for Moonstream application
16+
MOONSTREAM_GROUP_ID="$(brood groups create \
17+
--name moonstream \
18+
--username moonstream | jq -r .id)"
19+
20+
# Create Moonstream application itself
21+
MOONSTREAM_APPLICATION_ID="$(brood applications create \
22+
--group $MOONSTREAM_GROUP_ID \
23+
--name moonstream \
24+
--description moonstream | jq -r .id)"
25+
26+
VAR="$(cat <<EOF
27+
export MOONSTREAM_ADMIN_ACCESS_TOKEN=$MOONSTREAM_TOKEN_ID
28+
export MOONSTREAM_APPLICATION_ID=$MOONSTREAM_APPLICATION_ID
29+
EOF
30+
)"
31+
32+
echo "$VAR"

configs/docker_init_plan.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
# Create free group subscription, to be able create new groups
6+
python -m brood.cli plans create \
7+
--name "Free plan" \
8+
--description "free plan description" \
9+
--default_units 5 \
10+
--plan_type "seats" \
11+
--public True \
12+
--kv_key BUGOUT_GROUP_FREE_SUBSCRIPTION_PLAN

dev.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
# for this project installed.
66
set -e
77

8+
. /bugout/moonstream_app.env
9+
810
BROOD_HOST="${BROOD_HOST:-127.0.0.1}"
911
BROOD_PORT="${BROOD_PORT:-7474}"
1012
BROOD_APP_DIR="${BROOD_APP_DIR:-$PWD}"
1113
BROOD_ASGI_APP="${BROOD_ASGI_APP:-brood.api:app}"
1214
BROOD_UVICORN_WORKERS="${BROOD_UVICORN_WORKERS:-2}"
1315

16+
echo $MOONSTREAM_APPLICATION_ID
17+
1418
uvicorn --reload \
1519
--port "$BROOD_PORT" \
1620
--host "$BROOD_HOST" \

docker-compose.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ services:
77
build:
88
context: ./
99
dockerfile: ./Dockerfile
10-
entrypoint: configs/docker_compose_entrypoint.sh
1110
image: brood:latest
11+
entrypoint: ["/bin/sh","-c"]
12+
command:
13+
- |
14+
./configs/docker_init_migration.sh
15+
./configs/docker_init_plan.sh
16+
./dev.sh
1217
ports:
1318
- "127.0.0.1:7474:7474"
1419
# Specify environment file for compose setup
@@ -36,7 +41,7 @@ services:
3641
environment:
3742
POSTGRES_PASSWORD: postgres
3843
POSTGRES_USER: postgres
39-
POSTGRES_DB: brood_dev
44+
POSTGRES_DB: db_dev
4045
healthcheck:
4146
test: ["CMD", "psql", "-U", "postgres", "-c", "SELECT 1;"]
4247
interval: 5s

0 commit comments

Comments
 (0)