Skip to content

Commit dbd4aa2

Browse files
authored
Merge pull request #10 from jasonyang-ee/main
Add Action script to build and push docker image to registry
2 parents ac13216 + 152d64e commit dbd4aa2

4 files changed

Lines changed: 73 additions & 5 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'DockerBuild'
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
Build_And_Push:
10+
runs-on: ubuntu-22.04
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Log in to Github Docker Image Registry
20+
uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ secrets.TOKEN_GITHUB }}
25+
26+
# Uncomment to use Docker Hub
27+
# - name: Login to Docker Hub
28+
# uses: docker/login-action@v3
29+
# with:
30+
# username: ${{ secrets.USERNAME_DOCKERHUB }}
31+
# password: ${{ secrets.TOKEN_DOCKERHUB }}
32+
33+
- name: Docker Meta
34+
id: meta
35+
uses: docker/metadata-action@v4
36+
with:
37+
images: |
38+
ghcr.io/${{ github.actor }}/meme-search
39+
# Uncomment to use Docker Hub
40+
# ${{ secrets.DOCKERHUB_USERNAME }}/meme-search
41+
tags: type=ref,event=tag
42+
flavor: latest=true
43+
44+
- name: Set up QEMU
45+
uses: docker/setup-qemu-action@v3
46+
47+
- name: Set Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Build and Upload for AMD64 and ARM64
51+
uses: docker/build-push-action@v4
52+
with:
53+
context: .
54+
platforms: linux/amd64,linux/arm64
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ENV PYTHONPATH=.
1212

1313
COPY requirements.txt /home/requirements.txt
1414
COPY meme_search /home/meme_search
15+
COPY data/dbs /home/init
1516
COPY .streamlit /home/.streamlit
1617

1718
RUN pip3 install -r /home/requirements.txt
@@ -20,4 +21,6 @@ EXPOSE 8501
2021

2122
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
2223

23-
ENTRYPOINT ["streamlit", "run", "/home/meme_search/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
24+
COPY entrypoint.sh /home/entrypoint.sh
25+
RUN chmod +x /home/entrypoint.sh
26+
ENTRYPOINT ["/home/entrypoint.sh"]

docker-compose.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
services:
22
meme_search:
3-
build:
4-
context: .
5-
image: meme_search
3+
image: ghcr.io/neonwatty/meme_search:latest
64
container_name: meme_search
75
ports:
86
- 8501:8501
97
volumes:
10-
- ./data:/home/data
8+
- ./meme_search/database:/home/data/dbs # database persistence
9+
- ./meme_search/memes:/home/data/input # meme images
1110
## uncomment to enable GPU support for the container
1211
# deploy:
1312
# resources:

entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Check if database is empty, if so, copy the init files
4+
if [ -z "$(ls -A /home/data/dbs)" ]; then
5+
cp -r /home/init/* /home/data/dbs
6+
fi
7+
8+
# Start the streamlit app
9+
streamlit run /home/meme_search/app.py --server.port=8501 --server.address=0.0.0.0

0 commit comments

Comments
 (0)