Skip to content

fix dockerfile: missing libraries #60

fix dockerfile: missing libraries

fix dockerfile: missing libraries #60

Workflow file for this run

name: Build, Deploy, and Run on EC2
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set execute permissions for Maven Wrapper
run: chmod +x ./video-downloader-backend/mvnw
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build backend with Maven
run: |
./mvnw clean package -DskipTests
working-directory: ./video-downloader-backend
# Log in to Amazon ECR
- name: Log in to Amazon ECR
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
# Build and Push Docker images to ECR
- name: Build and Push Docker images
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_REGION: ${{ secrets.AWS_REGION }}
INSTA_SESSION: ${{ secrets.INSTA_SESSION }}
run: |
docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-backend \
--build-arg INSTA_SESSION="$INSTA_SESSION" ./video-downloader-backend
docker build -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-frontend ./video-downloader-frontend
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-backend
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-frontend
# Deploy Docker images to EC2
- name: Deploy Docker images to EC2
env:
HOST: ${{ secrets.AWS_EC2_HOST }}
USER: ${{ secrets.AWS_EC2_USER }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_REGION: ${{ secrets.AWS_REGION }}
INSTAGRAM_USERNAME: ${{ secrets.INSTAGRAM_USERNAME }}
INSTAGRAM_PASSWORD: ${{ secrets.INSTAGRAM_PASSWORD }}
run: |
echo "${{ secrets.AWS_EC2_PEM }}" > /tmp/key.pem
chmod 600 /tmp/key.pem
mkdir -p ~/.ssh
echo -e "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
# SSH into EC2 and pull the images from ECR
ssh -i /tmp/key.pem "$USER@$HOST" <<EOF
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com
docker network create my-app-network || true
docker stop backend frontend || true
docker rm backend frontend || true
docker pull $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-backend
docker pull $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-frontend
# Run backend and frontend with Instagram credentials passed as environment variables
docker run -d --network=my-app-network --name backend -p 8080:8080 \
-e INSTAGRAM_USERNAME="$INSTAGRAM_USERNAME" \
-e INSTAGRAM_PASSWORD="$INSTAGRAM_PASSWORD" \
$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-backend
docker run -d --network=my-app-network --name frontend -p 80:80 \
$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/video-downloader-frontend
EOF