Hi, I have the following dockerfile (backend.dockerfile
):
FROM python:3.10.7
WORKDIR /app
RUN apt-get update
RUN apt-get install -y coinor-cbc
# Install Poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \
cd /usr/local/bin && \
ln -s /opt/poetry/bin/poetry && \
poetry config virtualenvs.create false
# Copy poetry.lock* in case it doesn't exist in the repo
COPY ./pyproject.toml ./poetry.lock* /app/
# Allow installing dev dependencies to run tests
ARG INSTALL_DEV=true
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then POETRY_VIRTUALENVS_CREATE=false poetry install --no-root ; else POETRY_VIRTUALENVS_CREATE=false poetry install --no-root --no-dev ; fi"
COPY . /app
Here’s a snippet of my docker-compose.yml
file:
backend:
build:
context: backend
dockerfile: backend.dockerfile
command: bash -c "alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port 8888 --reload"
ports:
- '8888:8888'
tty: true
volumes:
- ./backend:/app/:cached
- ./.docker/.ipython:/root/.ipython:cached
env_file:
- ./backend/.env
Here’s a snipper of our render.yaml
services:
- type: web
name: BelfryAPI
env: docker
region: ohio
plan: pro
previewPlan: starter
dockerfilePath: ./backend/backend.dockerfile
dockerContext: ./backend
dockerCommand:
I would like the dockerCommand to run the same command as the command in docker-compose.yml
, but I seem to be unable to do so.
The following command, command: bash -c "alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port 8888 --reload"
works both within the dockerfile (as CMD bash -c "alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port 8888 --reload"
) and within docker-compose.yml
(command: bash -c "alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port 8888 --reload"
)
Would you be able to point us to a direction whether we can both run alembic and uvicorn using dockerCommand within render.yml. Thank you in advance for your help and patience!