joseamtalavera / lhm_inmo_app

0 stars 0 forks source link

Docker #1

Closed joseamtalavera closed 1 month ago

joseamtalavera commented 1 month ago

Starting Point in Local Machine

Installing Dockers in EC2

sudo apt update sudo apt install docker.io -y sudo systemctl start docker sudo systemctl enable docker sudo usermod -aG docker $USER newgrp docker docker --version

sudo apt install docker-compose

Connecting and Push to GitHub Container Registry (GHCR)

Logging in to Git Hub Container Registry - GHCR

token | docker login ghcr.io -u joseamtalavera --password-stdin

Before logging you need to build the changes in local:

docker build --build-arg REACT_APP_API_URL=https://app.lhainmobiliaria.es -t ghcr.io/joseamtalavera/lhm_inmo_app-frontend:latest ./client docker build -t ghcr.io/joseamtalavera/lhm_inmo_app-backend:latest ./server

docker tag lhm_inmo_app-frontend:latest ghcr.io/joseamtalavera/lhm_inmo_app-frontend:latest docker tag lhm_inmo_app-backend:latest ghcr.io/joseamtalavera/lhm_inmo_app-backend:latest

docker push ghcr.io/joseamtalavera/lhm_inmo_app-frontend:latest docker push ghcr.io/joseamtalavera/lhm_inmo_app-backend:latest

Pull and Run the images from the EC2

Before I need to login inside the EC2:

token | docker login ghcr.io -u joseamtalavera --password-stdin

Pull and Run all together more efficiently:

docker-compose -f docker-compose.prod.yml down docker-compose -f docker-compose.prod.yml pull docker-compose -f docker-compose.prod.yml up -d

docker ps docker-compose -f docker-compose.prod.yml logs -f

.....From this point, we carry on with the normal configuration in the EC2

Very Important

The flow is as follows:

Clean space from the Docker

docker system prune -a --volumes