diff --git a/.github/workflows/docker-build.yaml b/.github/workflows/docker-build.yaml index cd6464a..c1b1b6d 100644 --- a/.github/workflows/docker-build.yaml +++ b/.github/workflows/docker-build.yaml @@ -59,7 +59,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Docker build - run: bash scripts/docker/build.sh mlflow + run: bash scripts/docker/build.sh app - name: Login to GitHub Package Registry uses: docker/login-action@v2 with: @@ -67,4 +67,4 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GHCR_TOKEN }} - name: Docker push - run: bash scripts/docker/push.sh mlflow \ No newline at end of file + run: bash scripts/docker/push.sh app \ No newline at end of file diff --git a/app/app.py b/app/app.py new file mode 100644 index 0000000..7d74a5f --- /dev/null +++ b/app/app.py @@ -0,0 +1,26 @@ +import pandas as pd +import plotly.express as px +from dash import Dash, Input, Output, callback, dcc, html + +df = pd.read_csv( + "https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfiltered.csv" +) + +app = Dash() +server = app.server + +app.layout = [ + html.H1(children="Title of Dash App", style={"textAlign": "center"}), + dcc.Dropdown(df.country.unique(), "Canada", id="dropdown-selection"), + dcc.Graph(id="graph-content"), +] + + +@callback(Output("graph-content", "figure"), Input("dropdown-selection", "value")) +def update_graph(value: str) -> px.line: + dff = df[df.country == value] + return px.line(dff, x="year", y="pop") + + +if __name__ == "__main__": + app.run_server(host="0.0.0.0", port="8000") diff --git a/docker-compose.yaml b/docker-compose.yaml index 3038849..8151659 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,28 @@ services: + app: + image: ghcr.io/jbris/deep-root-gen:${APP_VERSION} + build: + context: . + dockerfile: ./dockerfiles/python/Dockerfile.${APP_VERSION} + args: + BUILD_DATE: date -u +'%Y-%m-%dT%H:%M:%SZ' + restart: always + stop_grace_period: 10s + environment: + MLFLOW_BACKEND_STORE_URI: $MLFLOW_BACKEND_STORE_URI + MLFLOW_S3_ENDPOINT_URL: http://minio:9000 + AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY + PREFECT_URL: http://prefect:4200/api + PREFECT_API_DATABASE_CONNECTION_URL: $PREFECT_API_DATABASE_CONNECTION_URL + ports: + - 8000:8000 + volumes: + - ./app/app.py:/app/app.py + command: > + gunicorn -b 0.0.0.0:8000 -w 4 app:server + mlflow: image: ghcr.io/jbris/deep-root-gen:${APP_VERSION} build: diff --git a/dockerfiles/python/Dockerfile.0.1.0 b/dockerfiles/python/Dockerfile.0.1.0 index 93eeb75..02b655f 100644 --- a/dockerfiles/python/Dockerfile.0.1.0 +++ b/dockerfiles/python/Dockerfile.0.1.0 @@ -12,6 +12,8 @@ COPY README.md README.md COPY deeprootgen deeprootgen +COPY app/app.py app.py + RUN apt-get update \ && apt-get install -y --no-install-recommends build-essential libpq-dev graphviz \ && apt-get clean \ @@ -40,4 +42,6 @@ ENV VIRTUAL_ENV=/app/.venv \ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} -RUN chmod -R 755 /app \ No newline at end of file +RUN chmod -R 755 /app + +EXPOSE 8000 \ No newline at end of file