Skip to content

Commit 6fc07b7

Browse files
committed
add docker files
1 parent 5190740 commit 6fc07b7

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

.github/workflows/build_publish.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Create and publish a Docker image to ghcr.io
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Log in to the Container registry
24+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
25+
with:
26+
registry: ${{ env.REGISTRY }}
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract metadata (tags, labels) for Docker
31+
id: meta
32+
uses: docker/metadata-action@v4
33+
with:
34+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
35+
tags: |
36+
type=raw,value={{date 'YYYYMMDD-HHmmss' tz='Europe/Stockholm'}}
37+
38+
- name: Build and push Docker image
39+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Select base image (can be ubuntu, python, shiny etc)
2+
FROM python:3.10-slim
3+
4+
# Create user name and home directory variables.
5+
# The variables are later used as $USER and $HOME.
6+
ENV USER=username
7+
ENV HOME=/home/$USER
8+
9+
# Add user to system
10+
RUN useradd -m -u 1000 $USER
11+
12+
# Set working directory (this is where the code should go)
13+
WORKDIR $HOME/datascience_toolkit
14+
15+
# Update system and install dependencies.
16+
RUN apt-get update && apt-get install --no-install-recommends -y \
17+
build-essential \
18+
software-properties-common
19+
20+
# Copy code and start script (this will place the files in home/username/)
21+
COPY .streamlit $HOME/datascience_toolkit/.streamlit
22+
COPY requirements.txt $HOME/datascience_toolkit/requirements.txt
23+
COPY pages $HOME/datascience_toolkit/pages/
24+
COPY images $HOME/datascience_toolkit/images/
25+
COPY data $HOME/datascience_toolkit/data/
26+
COPY Main.py $HOME/datascience_toolkit/Main.py
27+
COPY kgg_utils.py $HOME/datascience_toolkit/kgg_utils.py
28+
COPY start-script.sh $HOME/datascience_toolkit/start-script.sh
29+
30+
RUN pip install --no-cache-dir -r requirements.txt \
31+
&& chmod +x start-script.sh \
32+
&& chown -R $USER:$USER $HOME \
33+
&& rm -rf /var/lib/apt/lists/*
34+
35+
USER $USER
36+
EXPOSE 8501
37+
38+
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
39+
40+
ENTRYPOINT ["./start-script.sh"]

start-script.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
streamlit run Main.py --server.port=8501 --server.address=0.0.0.0

0 commit comments

Comments
 (0)