Skip to content
Snippets Groups Projects
Commit fb57ae23 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

add an entrypoint for running the db migrations in runtime

parent d483ea74
No related branches found
No related tags found
1 merge request!90include TRANSLATIONS_DIR as environment variable in the Docker image
Pipeline #84407 passed
......@@ -17,22 +17,15 @@ RUN pip install \
# NOTE: a real config must be mounted at /etc/gso/config.json when running the container
RUN mkdir -p /etc/gso && \
chown -R appuser:appgroup /etc/gso
COPY --chown=appuser:appgroup gso/oss-params-example.json /etc/gso/config.json
# Expose port 8080 for the FastAPI application
EXPOSE 8080
COPY --chown=appuser:appgroup gso/oss-params-example.json /app/config.json
# The app reads the configuration from this location.
# No need to set environment variables in your docker-compose.
ENV OSS_PARAMS_FILENAME=/etc/gso/config.json
ENV OSS_PARAMS_FILENAME=/app/config.json
# Set the environment variable for the translations directory
ENV TRANSLATIONS_DIR=/app/gso/translations/
# Run database migrations
RUN mv gso/migrations gso/migrations_temp
RUN PYTHONPATH=. python gso/main.py db init
RUN rm -rf gso/migrations && \
mv gso/migrations_temp gso/migrations
RUN PYTHONPATH=. python gso/main.py db upgrade heads
# Start the FastAPI application
CMD ["python", "-m", "uvicorn", "gso.main:app", "--host", "0.0.0.0", "--port", "8080"]
COPY --chown=appuser:appgroup --chmod=755 entrypoint.sh /app/entrypoint.sh
EXPOSE 8080
ENTRYPOINT ["/app/entrypoint.sh"]
#!/bin/sh
# Run database migrations
cd gso || exit 1
mv migrations migrations_temp && \
PYTHONPATH=.. python main.py db init && \
rm -rf migrations && \
mv migrations_temp migrations
PYTHONPATH=.. python main.py db upgrade heads
# Start the FastAPI application
cd ..
python -m uvicorn "gso.main:app" --host "0.0.0.0" --port 8080
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment