Add docker cache to CI #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Set up and start Docker services | |
on: [push, pull_request] | |
jobs: | |
setup-and-start: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/docker-save | |
key: ${{ runner.os }}-docker-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-docker- | |
- name: Load Docker layers | |
run: | | |
if [ -f /tmp/docker-save/image.tar ]; then | |
docker load -i /tmp/docker-save/image.tar | |
fi | |
- name: Rename key.env.example to key.env | |
run: mv key.env.example key.env | |
# Note: You might want to populate key.env via secrets or some other method if it has sensitive data. | |
- name: Create directories for persistent storage | |
run: mkdir -p .data/qdrant/ | |
- name: Build Docker images | |
run: docker-compose build | |
- name: Start services | |
run: docker-compose up -d | |
- name: Wait for the container to be reachable | |
run: | | |
for i in {1..30}; do # Try for up to 30 seconds (30 retries with 1-second sleep) | |
if curl -s http://localhost:8000/docs; then | |
echo "Container is up!" | |
exit 0 | |
else | |
echo "Waiting for container..." | |
sleep 1 | |
fi | |
done | |
echo "Container did not start in time!" | |
exit 1 |