diff --git a/.github/workflows/build_and_publish.yaml b/.github/workflows/build_and_publish.yaml new file mode 100644 index 0000000..7a2684e --- /dev/null +++ b/.github/workflows/build_and_publish.yaml @@ -0,0 +1,62 @@ +name: Build and Publish + +on: + push: + branches: + - main + + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Manual run' + required: false + type: boolean +jobs: + publish: + name: Publish to ghcr.io + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + include: + - dockerfile: ./Dockerfile + image: ghcr.io/${{ github.repository }}/kg_dashboard + permissions: + packages: write + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + uses: docker/metadata-action@v4 + id: meta + with: + images: ${{ matrix.image }} + tags: | + type=raw,value={{date 'YYYYMMDD'}} + + - name: Log in + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + uses: docker/build-push-action@v2 + with: + context: . + push: "${{ github.event_name != 'pull_request' }}" + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + file: ${{ matrix.dockerfile }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..90315c8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Select base image (can be ubuntu, python, shiny etc) +FROM python:3.12-slim + +# Create user name and home directory variables. +# The variables are later used as $USER and $HOME. +ENV USER=username +ENV HOME=/home/$USER + +# Add user to system +RUN useradd -m -u 1000 $USER + +# Set working directory (this is where the code should go) +WORKDIR $HOME/kg + +# Update system and install dependencies. +RUN apt-get update && apt-get install --no-install-recommends -y \ + build-essential \ + software-properties-common + +# Copy code and start script (this will place the files in home/username/) +COPY requirements.txt $HOME/kg/requirements.txt +COPY webapp $HOME/kg/webapp/ +COPY data/ $HOME/kg/data/ +COPY start-script.sh $HOME/kg/start-script.sh + +RUN pip install --no-cache-dir -r requirements.txt \ + && chmod +x start-script.sh \ + && chown -R $USER:$USER $HOME \ + && rm -rf /var/lib/apt/lists/* + +USER $USER +EXPOSE 8501 + +ENTRYPOINT ["./start-script.sh"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 5d272a1..0b543da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,4 +16,6 @@ openpyxl==3.1.2 matplotlib_venn==0.11.10 xgboost joblib==1.3.2 -treeinterpreter==0.2.3 \ No newline at end of file +treeinterpreter==0.2.3 +umap-learn==0.5.1 +streamlit==1.36.0 \ No newline at end of file diff --git a/start-script.sh b/start-script.sh new file mode 100644 index 0000000..ffd807e --- /dev/null +++ b/start-script.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +streamlit run webapp/AMR-KG_Database.py --server.port=8501 --server.address=0.0.0.0 \ No newline at end of file