mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-08 15:33:53 -05:00
Added proxy headers flag to FastAPI launch logic
[docker] add new BEHIND_PROXY env variable with false as default value [docker] added new script start.sh with frontend.sh logic plus logic to add proxy headers flag if BEHIND_PROXY is true [docker] removed frontend.sh [docker] created new folder docker in root and moved docker related files to it
This commit is contained in:
@@ -52,7 +52,8 @@ ENV TZ="UTC" \
|
||||
JAEGER_PROTOCOL="http" \
|
||||
JAGGER_PORT=4317 \
|
||||
ENDURAIN_HOST="http://localhost:8080" \
|
||||
GEOCODES_MAPS_API="changeme"
|
||||
GEOCODES_MAPS_API="changeme" \
|
||||
BEHIND_PROXY=false
|
||||
|
||||
# Set the working directory to /app/backend
|
||||
WORKDIR /app/backend
|
||||
@@ -71,13 +72,12 @@ COPY backend/app ./
|
||||
|
||||
# Copy the directory app contents to /app
|
||||
COPY --from=frontend-build /tmp/frontend/dist ./frontend/dist
|
||||
COPY frontend/app/.env ./frontend/.env
|
||||
|
||||
# Copy the entrypoint script
|
||||
COPY frontend_env.sh /docker-entrypoint.d/frontend_env.sh
|
||||
# Copy the entrypoint script for starting the FastAPI app
|
||||
COPY docker/start.sh /docker-entrypoint.d/start.sh
|
||||
|
||||
# Make the entrypoint script executable
|
||||
RUN chmod +x /docker-entrypoint.d/frontend_env.sh
|
||||
# Make the script executable
|
||||
RUN chmod +x /docker-entrypoint.d/start.sh
|
||||
|
||||
# Change ownership to non-root user
|
||||
RUN chown -R endurain:endurain ./
|
||||
@@ -88,5 +88,5 @@ USER endurain
|
||||
# Make port 80 available to the world outside this container
|
||||
EXPOSE 80
|
||||
|
||||
# Run FastAPI
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
|
||||
# Run the FastAPI app
|
||||
ENTRYPOINT ["/docker-entrypoint.d/start.sh"]
|
||||
@@ -1,11 +1,28 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Substitute MY_APP_ENDURAIN_HOST with the value of ENDURAIN_HOST
|
||||
if [ ! -z "$ENDURAIN_HOST" ]; then
|
||||
echo "Substituting MY_APP_ENDURAIN_HOST with $ENDURAIN_HOST"
|
||||
find /app/backend/frontend/dist -type f \( -name '*.js' -o -name '*.css' \) -exec sed -i "s|MY_APP_ENDURAIN_HOST|${ENDURAIN_HOST}|g" '{}' +
|
||||
fi
|
||||
|
||||
# Substitute MY_APP_STRAVA_CLIENT_ID with the value of STRAVA_CLIENT_ID
|
||||
if [ ! -z "$STRAVA_CLIENT_ID" ]; then
|
||||
echo "Substituting MY_APP_STRAVA_CLIENT_ID with $STRAVA_CLIENT_ID"
|
||||
find /app/backend/frontend/dist -type f \( -name '*.js' -o -name '*.css' \) -exec sed -i "s|MY_APP_STRAVA_CLIENT_ID|${STRAVA_CLIENT_ID}|g" '{}' +
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Starting FastAPI with BEHIND_PROXY=$BEHIND_PROXY"
|
||||
|
||||
# Base command as an array
|
||||
CMD=("uvicorn" "main:app" "--host" "0.0.0.0" "--port" "80")
|
||||
|
||||
# Add --proxy-headers if BEHIND_PROXY is true
|
||||
if [ "$BEHIND_PROXY" = "true" ]; then
|
||||
echo "Enabling proxy headers"
|
||||
CMD+=("--proxy-headers")
|
||||
fi
|
||||
|
||||
# Execute the command
|
||||
exec "${CMD[@]}"
|
||||
Reference in New Issue
Block a user