-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.54 KB
/
docker.yml
File metadata and controls
56 lines (47 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Docker Image CI
on:
push:
release:
types: [published]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract metadata
id: meta
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAG=${GITHUB_REF#refs/tags/}
else
TAG=${GITHUB_REF#refs/heads/}
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Build test Docker image
run: docker build --no-cache . --file Dockerfile --tag test-image
- name: Test container startup
run: |
docker run -d --name test-container -p 8080:8080 test-image
sleep 10
if docker ps | grep -q test-container; then
echo "Container is running successfully"
curl -sf http://localhost:8080/health || { echo "Health check failed"; docker logs test-container; exit 1; }
echo "Health check passed"
else
echo "Container failed to start"
docker logs test-container
exit 1
fi
docker stop test-container || true
docker rm test-container
- name: Build Docker image
run: docker build . --file Dockerfile --tag virtualflybrain/vfbquery:${{ steps.meta.outputs.tag }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Push Docker image
run: docker push virtualflybrain/vfbquery:${{ steps.meta.outputs.tag }}