fastapi-sqlmodel-alembic
fastapi-sqlmodel-alembic copied to clipboard
This is really awful
I don't know how to repair this but I didn't find any way to do "alembic upgrade head" in docker-compose. But the fact that it's useless is really disgusting. Usually people use docker for simple work on servers and it's main idea to unite a big amount of commads instead of exexcuting it by hands. So, you didn't find how to fix it and just said "do a docker-compose exec web alembic upgrade head every time you need to up docker-compose". I hate myself that i didn't find how to fix it but more I hate for this subquality work
I have no idea about what people thinking when they star this
Chill dawg
Well, actually you can tell alembic to migrate your database schema before running your application, hope that is actually the solution you're looking for. Change your service definition inside docker-compose into this:
version: "3"
services:
app:
build: .
command: bash -c "alembic upgrade head && uvicorn main:app"
volumes:
- "./:/app"
ports:
- "8000:8000"
depends_on:
- db
Here is for the Dockerfile (pretty standard):
FROM python:3.8
# Set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY . /app
RUN pip install -r /app/requirements.txt
EXPOSE 8000
@vishIGOR thanks for being so constructive :roll_eyes: If you see things you don't like on a small project like this, you should implement solutions for it yourself.