Skip to content

Commit

Permalink
ci(DockerFile): dashboard build on image
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotAmn committed Jan 16, 2025
1 parent 2a519d2 commit 7a443ef
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
### Example user template template
### Example user template

# Project dashboard
web/

# IntelliJ project files
.idea
*.iml
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@
/alembic.ini
/.idea
/scrapers-config.json
!/dashboard_build/.gitkeep
/dashboard_build/*
18 changes: 17 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,34 @@ WORKDIR /app

RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
npm \
nodejs \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir gunicorn

WORKDIR /app/web
COPY web/package.json web/package-lock.json ./
RUN npm install
COPY web ./
RUN npm run build

# Déplacer les fichiers build React
WORKDIR /app
RUN mkdir -p /app/dashboard_build && \
mv /app/web/build/* /app/dashboard_build



# Default environment variables
ENV PYTHONPATH=/app \
PYTHONUNBUFFERED=1 \
FLASK_ENV=production \
FLASK_DEBUG=0
FLASK_DEBUG=0 \
DASHBOARD_BUILD_PATH=/app/dashboard_build

RUN useradd -m -s /bin/bash appuser && \
chown -R appuser:appuser /app
Expand Down
12 changes: 11 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_app():

init_services()

flask_app = Flask(__name__)
flask_app = Flask(__name__, static_folder=os.getenv("DASHBOARD_BUILD_PATH", "../web/build"))

# Load the routes
load_scrapers_routes(flask_app)
Expand All @@ -81,6 +81,16 @@ def create_app():
load_sync_routes(flask_app)
load_auth_routes(flask_app)

# Serve React App
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def serve(path):
if path != "" and os.path.exists(app.static_folder + '/' + path):
return send_from_directory(app.static_folder, path)
else:
return send_from_directory(app.static_folder, 'index.html')


CORS(flask_app)

return flask_app
Expand Down
Empty file removed dashboard_build/.gitkeep
Empty file.

0 comments on commit 7a443ef

Please sign in to comment.