Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
YojanaGadiya committed Jun 24, 2024
1 parent 7fde940 commit 02e90ed
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 1 deletion.
62 changes: 62 additions & 0 deletions .github/workflows/build_and_publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ openpyxl==3.1.2
matplotlib_venn==0.11.10
xgboost
joblib==1.3.2
treeinterpreter==0.2.3
treeinterpreter==0.2.3
umap-learn==0.5.1
streamlit==1.36.0
3 changes: 3 additions & 0 deletions start-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

streamlit run webapp/AMR-KG_Database.py --server.port=8501 --server.address=0.0.0.0

0 comments on commit 02e90ed

Please sign in to comment.