diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ca86535 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.7' + +services: + api: + build: ./services/api + command: uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8000 + volumes: + - ./services/api/:/opt/fast_api/ + ports: + - 8002:8000 diff --git a/services/api/Dockerfile b/services/api/Dockerfile index e69de29..cc89528 100644 --- a/services/api/Dockerfile +++ b/services/api/Dockerfile @@ -0,0 +1,23 @@ +# pull official base image +FROM python:3.8.1-alpine + +# set work directory +WORKDIR /opt/fast_api + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# copy requirements file +COPY ./requirements.txt /opt/fast_api/requirements.txt + +# install dependencies +RUN set -eux \ + && apk add --no-cache --virtual .build-deps build-base \ + libressl-dev libffi-dev gcc musl-dev python3-dev postgresql-dev \ + && pip install --upgrade pip setuptools wheel \ + && pip install -r /opt/fast_api/requirements.txt \ + && rm -rf /root/.cache/pip + +# copy project +COPY . /opt/fast_api/ \ No newline at end of file diff --git a/services/api/app/main.py b/services/api/app/main.py index e69de29..c07d4eb 100644 --- a/services/api/app/main.py +++ b/services/api/app/main.py @@ -0,0 +1,8 @@ +from fastapi import FastAPI + +app = FastAPI() + + +@app.get('/ping') +def pong(): + return {"ping": "pong!"}