Skip to content

Commit

Permalink
Fix docker building
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Natalenko committed Nov 26, 2023
1 parent ca16154 commit d52b555
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions docker/bot.dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ WORKDIR /app
COPY ./pyproject.toml ./poetry.lock* /app/
RUN poetry install --no-interaction --no-ansi --no-root --without dev

COPY ./docker/pre-start.sh ./docker/start.sh /app/
RUN chmod +x /app/start.sh /app/pre-start.sh
ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh /
COPY /start.sh /app/
RUN chmod +x /app/start.sh /wait-for-it.sh

COPY ./inclusive_dance_bot /app/inclusive_dance_bot

ENV PYTHONPATH=/app
CMD ["/app/start.sh"]
4 changes: 3 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ services:
bot:
image: andytakker/inclusive_dance_bot:latest
restart: unless-stopped
command: /wait-for-it.sh -t 15 -h db -p 5432 -- /app/start.sh
environment:
POSTGRES_HOST: db
POSTGRES_PORT: 5432
POSTGRES_USER: $POSTGRES_USER
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
POSTGRES_DB: $POSTGRES_DB
POSTGRES_URL: postgresql+asyncpg://$POSTGRES_USER:$POSTGRES_PASSWORD@db:5432/$POSTGRES_DB

PG_URL: postgresql+asyncpg://$POSTGRES_USER:$POSTGRES_PASSWORD@db:5432/$POSTGRES_DB

REDIS_HOST: redis
REDIS_PORT: 6379
Expand Down
4 changes: 0 additions & 4 deletions docker/pre-start.sh

This file was deleted.

5 changes: 0 additions & 5 deletions docker/start.sh

This file was deleted.

4 changes: 4 additions & 0 deletions inclusive_dance_bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ def main() -> None:
) as loop:
log.info("Entrypoint started")
loop.run_forever()


if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions inclusive_dance_bot/db/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def main() -> None:
alembic.parser.formatter_class = argparse.ArgumentDefaultsHelpFormatter
alembic.parser.add_argument(
"--pg-url",
default=os.getenv("POSTGRES_URL", DEFAULT_PG_URL),
help="Database URL [env var: POSTGRES_URL]",
default=os.getenv("PG_URL", DEFAULT_PG_URL),
help="Database URL [env var: PG_URL]",
)

options = alembic.parser.parse_args()
Expand Down
1 change: 0 additions & 1 deletion inclusive_dance_bot/db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def make_alembic_config(cmd_opts: Namespace, base_path: Path = PROJECT_PATH) ->
alembic_location = config.get_main_option("script_location")
if not alembic_location:
raise ValueError
print(alembic_location)
if not os.path.isabs(alembic_location):
config.set_main_option("script_location", str(base_path / alembic_location))

Expand Down
6 changes: 6 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /usr/bin/env bash
python -m inclusive_dance_bot.db --pg-url $PG_URL upgrade head

python /app/inclusive_dance_bot/init_data.py

python -m inclusive_dance_bot
1 change: 0 additions & 1 deletion test.py

This file was deleted.

0 comments on commit d52b555

Please sign in to comment.