This repository contains GitHub Actions workflows for deploying a MEARN (MongoDB, Express.js, Angular, React, Node.js) stack application. The workflows offer two deployment methods: one using Docker Hub for image storage and distribution, and the other deploying directly to the server without Docker Hub. These workflows provide flexibility and options for users based on their deployment preferences and constraints.
Workflow Description:
- Build Docker Images: The workflow builds Docker images for the frontend, backend, and appew components of the MEARN stack application.
- Login to Docker Hub: It securely logs in to Docker Hub using provided credentials (DOCKER_USERNAME and DOCKER_PASSWORD).
- Push Docker Images: After logging in, the workflow pushes the built Docker images for the frontend, backend, and appew components to Docker Hub, making them accessible for deployment.
- Deploy to Server: The Docker images pushed to Docker Hub are then deployed to the server using SSH. Existing Docker containers for the application components are stopped and removed, and the latest Docker images are pulled from Docker Hub. New Docker containers are then run on the server to deploy the MEARN stack application.
- Cleanup: At the end of the workflow, temporary resources are cleaned up and the workflow stops.
Workflow Description:
- Build Docker Images: Similarly, this workflow builds Docker images for the frontend, backend, and appew components.
- Save Docker Images as Tar Archives: Instead of pushing to Docker Hub, the workflow saves the Docker images as tar archives.
- Upload to Server: Using SSH, the tar archives containing the Docker images are securely uploaded to the server.
- Deploy from Server: On the server side, the uploaded Docker images are loaded and deployed directly, eliminating the need for Docker Hub.
- Cleanup: Temporary resources are cleaned up and the workflow stops.
Both methods offer flexibility in deployment options. Method 1 leverages Docker Hub for image storage and distribution, while Method 2 provides a direct route for users who prefer not to use Docker Hub or who face constraints such as limited Docker Hub storage or privacy concerns.
- DOCKER_USERNAME: The username used to authenticate with Docker Hub for pushing Docker images.
- DOCKER_PASSWORD: The password used to authenticate with Docker Hub for pushing Docker images.
- SERVER_HOST: The hostname or IP address of the deployment server.
- SERVER_USERNAME: The username used to authenticate with the deployment server via SSH.
- SERVER_PASSWORD: The password used to authenticate with the deployment server via SSH.
- SERVER_PORT: The port number used for SSH connection to the deployment server.
- SERVER_USERNAME_ROOT: The username of the new user created specifically for running Docker on the server for security purposes.
- SERVER_PASSWORD_ROOT: The password of the new user created specifically for running Docker on the server for security purposes.