Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Added support for docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowXBoss696 committed May 19, 2023
1 parent f78c12d commit 7beaa7c
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 144 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__/
*.py[cod]
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 0 additions & 133 deletions .idea/workspace.xml

This file was deleted.

21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# Dockerfile
# Uses multi-stage builds requiring Docker 17.05 or higher
# See https://docs.docker.com/develop/develop-images/multistage-build/

# Creating a python base with shared environment variables
FROM python:3.11-slim as python-base

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

RUN python3 -m venv /pyenv

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT /docker-entrypoint.sh $0 $@
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT /entrypoint.sh $0 $@

WORKDIR /opt


FROM python-base as requirements
# Installing required dependencies
FROM python-base as setup

ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
Expand All @@ -25,9 +31,12 @@ COPY pyproject.toml poetry.lock ./
RUN . /pyenv/bin/activate && poetry install --no-interaction --no-root --only main


# 'production' stage uses the clean 'python-base' stage and copyies
# in only our runtime deps that were installed in the 'setup' stage
FROM python-base as production

COPY --from=requirements /pyenv /pyenv
COPY --from=setup /pyenv /pyenv
COPY jukebox ./jukebox

CMD ["uvicorn", "jukebox.main:app"]
EXPOSE 8000
CMD ["uvicorn", "jukebox.main:app", "--host", "0.0.0.0", "--port", "8000"]
47 changes: 47 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '3.8'

services:
webapp:
container_name: jukebox-webapp
build:
context: .
command: ["uvicorn", "jukebox.main:app", "--host", "0.0.0.0", "--port", "8000"]
environment:
DATABASE_URL: postgres://postgres:admin123@database:5432/jukebox
volumes:
- ./jukebox:/opt/jukebox
ports:
- "8000:8000"
depends_on:
- migrate
- database
links:
- database
restart: always

database:
container_name: jukebox-database
image: postgres
environment:
POSTGRES_PASSWORD: admin123
POSTGRES_DB: jukebox
volumes:
- pg_data:/var/lib/postgresql/data
restart: always

migrate:
container_name: jukebox-migrate
build:
context: .
command: ["python3", "jukebox/database/migrations.py"]
environment:
DATABASE_URL: postgres://postgres:admin123@database:5432/jukebox
volumes:
- ./jukebox:/opt/jukebox
depends_on:
- database
links:
- database

volumes:
pg_data:
1 change: 1 addition & 0 deletions docker-entrypoint.sh → entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set -e
. /pyenv/bin/activate

# You can put other setup logic here
export PYTHONPATH="${PYTHONPATH}:/opt/"

# Evaluating passed command:
exec "$@"
6 changes: 5 additions & 1 deletion misc/copyright
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Copyright (c) 2023 JukeBox Developers - All Rights Reserved
# This file is part of the JukeBox Music App and is released under the "MIT License Agreement"
# Please see the LICENSE file that should have been included as part of this package
# Please see the LICENSE file that should have been included as part of this package

Copyright (c) $originalComment.match("Copyright \(c\) (\d+)", 1, "-", "$today.year")$today.year JukeBox Developers - All Rights Reserved
This file is part of the JukeBox Music App and is released under the "MIT License Agreement"
Please see the LICENSE file that should have been included as part of this package

0 comments on commit 7beaa7c

Please sign in to comment.