Skip to content

Commit df55526

Browse files
authored
Update docker-image.yml
1 parent 26cfc26 commit df55526

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Image CI
1+
name: Docker Image CI with ngrok for Streamlit
22

33
on:
44
push:
@@ -7,19 +7,34 @@ on:
77
branches: [ "main" ]
88

99
jobs:
10-
11-
build:
12-
10+
build-and-expose:
1311
runs-on: ubuntu-latest
1412

1513
steps:
16-
- uses: actions/checkout@v4
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set image tag
18+
run: echo "IMAGE_TAG=chatbot:$(date +%s)" >> $GITHUB_ENV
1719

18-
- name: Build the Docker image
20+
- name: Build Docker image
21+
run: docker build . --file Dockerfile --tag ${{ env.IMAGE_TAG }}
22+
23+
- name: Run Docker container
24+
run: docker run -d -p 8501:8501 --name chatbot ${{ env.IMAGE_TAG }}
25+
26+
- name: Install ngrok
1927
run: |
20-
IMAGE_TAG=chatbot:$(date +%s)
21-
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
22-
docker build . --file Dockerfile --tag $IMAGE_TAG
28+
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null
29+
echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list
30+
sudo apt update && sudo apt install ngrok
2331
24-
- name: Run the Docker container
25-
run: docker run ${{ env.IMAGE_TAG }}
32+
- name: Start ngrok tunnel to Streamlit
33+
env:
34+
NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }}
35+
run: |
36+
ngrok config add-authtoken $NGROK_AUTHTOKEN
37+
nohup ngrok http 8501 > ngrok.log &
38+
sleep 5
39+
echo "🔗 Public URL:"
40+
curl -s http://127.0.0.1:4040/api/tunnels | jq -r '.tunnels[0].public_url'

0 commit comments

Comments
 (0)