Install Pino logging library #118
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: Build and Deploy to DigitalOcean | |
on: | |
push: | |
branches: ["main"] | |
env: | |
DOCKER_REPO: atomicsearch/massiveprediction | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout files | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push to Docker Hub | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ env.DOCKER_REPO }}:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout files | |
uses: actions/checkout@v4 | |
- name: Deploy to DigitalOcean Droplet | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSHKEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
script: | | |
# Check if Docker is installed, if not, install it | |
if ! command -v docker &> /dev/null | |
then | |
curl -fsSL https://get.docker.com -o get-docker.sh | |
sh get-docker.sh | |
fi | |
# Check if Docker Compose is installed, if not, install it | |
if ! command -v docker-compose &> /dev/null | |
then | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
fi | |
# Login to Docker Hub | |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} | |
# Pull the latest image | |
docker pull ${{ env.DOCKER_REPO }}:latest | |
# Copy SSL certificate and key files to the server | |
mkdir -p ssl | |
echo "${{ secrets.SSL_CERTIFICATE }}" > ssl/certificate.crt | |
echo "${{ secrets.SSL_PRIVATE_KEY }}" > ssl/private.key | |
# Stop and remove the existing containers (if any) | |
docker-compose -f docker-compose.production.yml down | |
# Deploy the updated containers | |
docker-compose -f docker-compose.production.yml up -d | |
# Prune unused Docker resources | |
docker system prune -f |