Skip to content

Commit b1a9b1a

Browse files
authored
Revert "Added db migration to move heartbeat templates into dedicated service…" (#2507)
This reverts commit 2d70cc8.
1 parent 2d70cc8 commit b1a9b1a

File tree

7 files changed

+182
-131
lines changed

7 files changed

+182
-131
lines changed

docker-compose.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
version: '3'
2+
3+
services:
4+
db:
5+
image: postgres:11.16@sha256:5d2aa4a7b5f9bdadeddcf87cf7f90a176737a02a30d917de4ab2e6a329bd2d45
6+
volumes:
7+
- ./local/initdb:/docker-entrypoint-initdb.d
8+
environment:
9+
POSTGRES_USER: postgres
10+
POSTGRES_PASSWORD: chummy
11+
ports:
12+
- "5432:5432"
13+
expose:
14+
- "5432"
15+
command:
16+
- "postgres"
17+
- "-c"
18+
- "listen_addresses=*"
19+
restart: always
20+
redis:
21+
image: redis:6.2@sha256:7919fdd5300e7abf7ae95919e6f144b37c55df16553302dbbcc7495a5aa0c079
22+
web:
23+
image: notification-api
24+
restart: always
25+
build:
26+
context: .
27+
dockerfile: local/Dockerfile
28+
environment:
29+
- REDIS_URL=redis://redis:6379/0
30+
- SQLALCHEMY_DATABASE_URI=postgres://postgres:chummy@db:5432/notification_api
31+
entrypoint: local/scripts/notify-web-entrypoint.sh
32+
command: >
33+
bash -c "make generate-version-file && make run"
34+
volumes:
35+
- .:/app
36+
ports:
37+
- "6011:6011"
38+
depends_on:
39+
- db
40+
- redis
41+
beat:
42+
image: notification-api
43+
restart: on-failure
44+
build:
45+
context: .
46+
dockerfile: local/Dockerfile
47+
environment:
48+
- REDIS_URL=redis://redis:6379/0
49+
- SQLALCHEMY_DATABASE_URI=postgres://postgres:chummy@db:5432/notification_api
50+
entrypoint: local/scripts/notify-worker-entrypoint.sh
51+
command: >
52+
bash -c "sh scripts/run_celery_beat.sh"
53+
volumes:
54+
- .:/app
55+
depends_on:
56+
- db
57+
- redis
58+
- web
59+
worker:
60+
image: notification-api
61+
restart: on-failure
62+
build:
63+
context: .
64+
dockerfile: local/Dockerfile
65+
environment:
66+
- REDIS_URL=redis://redis:6379/0
67+
- SQLALCHEMY_DATABASE_URI=postgres://postgres:chummy@db:5432/notification_api
68+
entrypoint: local/scripts/notify-worker-entrypoint.sh
69+
command: >
70+
bash -c "[[ -f /tmp/celery.pid ]] && rm /tmp/celery.pid; sh /app/scripts/run_celery.sh"
71+
volumes:
72+
- .:/app
73+
depends_on:
74+
- db
75+
- redis
76+
- web
77+
worker_sms:
78+
image: notification-api
79+
restart: on-failure
80+
build:
81+
context: .
82+
dockerfile: local/Dockerfile
83+
environment:
84+
- REDIS_URL=redis://redis:6379/0
85+
- SQLALCHEMY_DATABASE_URI=postgres://postgres:chummy@db:5432/notification_api
86+
entrypoint: local/scripts/notify-worker-entrypoint.sh
87+
command: >
88+
bash -c "sh /app/scripts/run_celery_sms.sh"
89+
volumes:
90+
- .:/app
91+
depends_on:
92+
- db
93+
- redis
94+
- web
95+
tests:
96+
image: notification-api-tests
97+
restart: "no"
98+
build:
99+
context: .
100+
dockerfile: ci/Dockerfile.test
101+
environment:
102+
- REDIS_URL=redis://redis:6379/1
103+
- SQLALCHEMY_DATABASE_URI=postgres://postgres:chummy@db:5432/test_notification_api
104+
- SQLALCHEMY_DATABASE_READER_URI=postgres://reader:chummy@db:5432/test_notification_api
105+
entrypoint: local/scripts/notify-worker-entrypoint.sh
106+
command: >
107+
bash -c "/app/scripts/run_tests.sh"
108+
volumes:
109+
- .:/app
110+
depends_on:
111+
- db

local/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.12-alpine3.20@sha256:5049c050bdc68575a10bcb1885baa0689b6c15152d8a56a7e399fb49f783bf98
2+
3+
ENV PYTHONDONTWRITEBYTECODE 1
4+
ENV POETRY_VERSION "1.7.1"
5+
6+
RUN apk add --no-cache bash build-base git gcc musl-dev postgresql-dev g++ make libffi-dev libmagic libcurl curl-dev && rm -rf /var/cache/apk/*
7+
8+
# update pip
9+
RUN python -m pip install wheel poetry==${POETRY_VERSION}
10+
11+
RUN set -ex && mkdir /app
12+
13+
WORKDIR /app
14+
15+
COPY . /app
16+
17+
RUN poetry install
18+
19+
ENV PORT=6011
20+
21+
ARG GIT_SHA
22+
ENV GIT_SHA ${GIT_SHA}
23+
24+
CMD ["sh", "-c", "poetry run gunicorn -c gunicorn_config.py application"]

local/initdb/notify-db-entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set -ex
2+
3+
###################################################################
4+
# This script will get executed *once* the Docker container has
5+
# been built. Commands that need to be executed with all available
6+
# tools and the filesystem mount enabled should be located here.
7+
#
8+
# The PostgreSQL Docker image has an extension mechanism that does
9+
# not necessitate to override the entrypoint or main command. One
10+
# simply has to copy a shell script into the
11+
# /docker-entrypoint-initdb.d/ initialization folder.
12+
###################################################################
13+
14+
# Notify database setup.
15+
createdb --user=postgres notification_api
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -x
3+
4+
###################################################################
5+
# This script will get executed *once* the Docker container has
6+
# been built. Commands that need to be executed with all available
7+
# tools and the filesystem mount enabled should be located here.
8+
###################################################################
9+
10+
cd /app
11+
12+
make generate-version-file
13+
14+
# Upgrade schema of the notification_api database.
15+
flask db upgrade
16+
17+
# Bubble up the main Docker command to container.
18+
exec "$@"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -x
3+
4+
###################################################################
5+
# This script will get executed *once* the Docker container has
6+
# been built. Commands that need to be executed with all available
7+
# tools and the filesystem mount enabled should be located here.
8+
###################################################################
9+
10+
cd /app
11+
12+
# Bubble up the main Docker command to container.
13+
exec "$@"

migrations/versions/0475_change_notification_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ def upgrade():
1919

2020

2121
def downgrade():
22-
op.execute("UPDATE notification_status_types set name = 'pinpoint-failure' where name = 'provider-failure'")
22+
pass

migrations/versions/0480_move_heartbeat_templates.py

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

0 commit comments

Comments
 (0)