Skip to content

Simplify CMD: Remove shell parameter expansion, rely on ENV defaults #31

Simplify CMD: Remove shell parameter expansion, rely on ENV defaults

Simplify CMD: Remove shell parameter expansion, rely on ENV defaults #31

Workflow file for this run

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: Test NGINX configuration
run: |
UPSTREAM_SERVER=owl.virtualflybrain.org:80 CACHE_MAX_SIZE=20g DNS_RESOLVER="8.8.8.8 1.1.1.1" envsubst '${UPSTREAM_SERVER} ${CACHE_MAX_SIZE} ${DNS_RESOLVER}' < nginx.conf.template > test-nginx.conf
docker run --rm -v $(pwd)/test-nginx.conf:/tmp/nginx.conf nginx:1.26-alpine nginx -t -c /tmp/nginx.conf
- 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 test-image
sleep 5
if docker ps | grep -q test-container; then
echo "Container is running successfully"
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/owl_cache:${{ 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/owl_cache:${{ steps.meta.outputs.tag }}