From f831462082691efe02f9328b5e0b18a94ed2dbac Mon Sep 17 00:00:00 2001 From: Antoine Gaudron-desjardins <antoine.gaudrondesjardins@student-cs.fr> Date: Mon, 4 Jul 2022 17:38:39 +0200 Subject: [PATCH] add docker-compose --- backend/Dockerfile | 23 +++++++++++++++++++++++ backend/docker-compose.yml | 16 +++++++++++++++- backend/requirements.txt | 3 +++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 backend/Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..2bf67b8 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.9 AS build + +## virtualenv +RUN python3 -m venv /venv +ENV PATH="/venv/bin:$PATH" + +## add and install requirements +RUN pip install --upgrade pip && pip install pip-tools +COPY ./requirements.txt ./ +RUN pip install -r requirements.txt + + + +FROM python:3.9 AS runtime + +EXPOSE 80 +ENV PATH="/venv/bin:$PATH" + +COPY --from=build /venv /venv +WORKDIR /backend +COPY . . + +ENTRYPOINT ["python3", "main.py"] \ No newline at end of file diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index abb808e..055a167 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -8,4 +8,18 @@ services: env_file: .env command: ["mysqld", "--authentication-policy=mysql_native_password"] ports: - - "3306:3306" \ No newline at end of file + - "3306:3306" + + app: + container_name: "app" + build: . + depends_on: + - db + restart: always + ports: + - 8000:80 + env_file: .env + environment: + DB_HOST: db + links: + - db \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt index c5e51aa..dd60603 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -12,3 +12,6 @@ sniffio==1.2.0 starlette==0.19.1 typing-extensions==4.2.0 uvicorn==0.17.6 +SQLAlchemy==1.4.19 +python-dotenv==0.18.0 +PyMySQL==1.0.2 \ No newline at end of file -- GitLab