Skip to content

Commit

Permalink
Refactor docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
EduKav1813 committed Jul 8, 2024
1 parent 5e331b2 commit 62a4495
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 48 deletions.
6 changes: 3 additions & 3 deletions docker/web/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ ENV PYTHONPATH=${PYTHONPATH}:${PWD}
RUN pip3 install poetry
RUN poetry config virtualenvs.create false

COPY pyproject.toml poetry.lock /app/
COPY pyproject.toml /app/
COPY poetry.lock /app/

WORKDIR /app
RUN poetry install --no-dev
COPY . .

#default config
ENV SECRET_KEY secret
ENV DB_PATH /data/whoisdevices.db
ENV SECRET_KEY S3cret

RUN mkdir /data && chown nobody /data
VOLUME ["/data"]
Expand Down
26 changes: 9 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
version: '3'
services:
rabbitmq:
image: 'rabbitmq:3.6-management-alpine'
ports:
- '5672:5672'
- '15672:15672'

web:
build: ./docker/web
build: .
environment:
# you should change secret key
- SECRET_KEY=<your_secret_key>
- DB_PATH=/data/whoisdevices.db
- APP_DB_DIALECT=postgresql
- APP_DB_NAME=whohacks
- APP_DB_USER=whohacks
- APP_DB_PASSWORD=S3cret
- APP_DB_HOST=postgres
- APP_DB_PORT=5432
#- APP_OAUTH_OPENID="http://sso.hsp.sh/auth/realms/hsp/.well-known/openid-configuration"

ports:
# use 127.0.0.1:8000:8000
- "8000:8000"
Expand All @@ -31,15 +32,6 @@ services:
- POSTGRES_USER=whohacks
- POSTGRES_DB=whohacks

worker:
build: ./docker/worker
environment:
- DB_PATH=/data/whoisdevices.db
volumes:
- database:/data
- /etc/localtime:/etc/localtime:ro
restart: always

volumes:
database:

25 changes: 0 additions & 25 deletions docker/worker/Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export APP_DB_DIALECT="postgres"
export APP_DB_DIALECT="postgresql"
export APP_DB_NAME="whohacks"
export APP_DB_USER="whohacks"
export APP_DB_PASSWORD="S3cret"
Expand Down
2 changes: 1 addition & 1 deletion helpers/db_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("db_create")

logger.info("connect to db at {}".format(os.environ.get("DB_PATH", "whoisdevices.db")))
# logger.info("connect to db at {}".format(os.environ.get("DB_PATH", "whoisdevices.db")))
db.connect()
logger.info("creating tables")
db.create_tables([Device, User])
Expand Down
2 changes: 1 addition & 1 deletion whois/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
db_name, user=db_user, password=db_password, host=db_host, port=db_port
)
else:
raise RuntimeError("Unknown db dialect (envvar APP_DB_DIALECT)")
raise RuntimeError(f"Unknown db dialect '{db_dialect}' (envvar APP_DB_DIALECT)")


class User(pw.Model):
Expand Down

0 comments on commit 62a4495

Please sign in to comment.