{"id":26688161,"url":"https://github.com/juliusmarkwei/node-image-ecr","last_synced_at":"2025-03-26T13:17:55.661Z","repository":{"id":280658933,"uuid":"942730024","full_name":"juliusmarkwei/node-image-ECR","owner":"juliusmarkwei","description":"Pushing Node App image to Amazon Elastic Container Registry","archived":false,"fork":false,"pushed_at":"2025-03-17T11:35:44.000Z","size":147,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T12:40:02.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliusmarkwei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-04T15:24:34.000Z","updated_at":"2025-03-17T11:35:47.000Z","dependencies_parsed_at":"2025-03-04T16:40:12.042Z","dependency_job_id":null,"html_url":"https://github.com/juliusmarkwei/node-image-ECR","commit_stats":null,"previous_names":["juliusmarkwei/node-image-ecr"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusmarkwei%2Fnode-image-ECR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusmarkwei%2Fnode-image-ECR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusmarkwei%2Fnode-image-ECR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliusmarkwei%2Fnode-image-ECR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliusmarkwei","download_url":"https://codeload.github.com/juliusmarkwei/node-image-ECR/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245659047,"owners_count":20651526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T13:17:55.074Z","updated_at":"2025-03-26T13:17:55.648Z","avatar_url":"https://github.com/juliusmarkwei.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS Microservice Labs - Week 4\n\nThis project demonstrates how to build and push a Docker image to Amazon Elastic Container Registry (ECR) using GitHub Actions. The Docker image is built from a Node.js application and is automatically pushed to ECR whenever changes are pushed to the `main` branch.\n\n## Prerequisites\n\n-   AWS Account\n-   AWS CLI installed and configured\n-   Docker installed\n-   GitHub repository with the following secrets configured:\n    -   `AWS_ACCESS_KEY_ID`\n    -   `AWS_SECRET_ACCESS_KEY`\n    -   `AWS_REGION`\n    -   `AWS_ACCOUNT_ID`\n\n## Project Structure\n\n```\n/week4\n├── .github\n│   └── workflows\n│       └── upload-to-s3.yml\n├── .gitignore\n├── src\n│   └── index.js\n│   └── /confg\n│       └── db.ts\n|   |__ /controllers\n|   .\n|   .\n|   .\n├── Dockerfile\n├── package.json\n└── README.md\n```\n\n## Dockerfile\n\nThe `Dockerfile` defines the steps to build the Docker image for the Node.js application.\n\n```dockerfile\n# filepath: /Users/watchmker/Library/CloudStorage/OneDrive-AmaliTechgGmbH/Amalitech/Labs/aws-micorservice-labs/week4/Dockerfile\nFROM node:14.15.4\n\nWORKDIR /app\n\nCOPY package.json /app\n\nRUN npm install\n\nCOPY . .\n\nEXPOSE 3000\n\nCMD [\"npm\", \"run\", \"dev\"]\n```\n\n## GitHub Actions Workflow\n\nThe GitHub Actions workflow is defined in `.github/workflows/upload-to-s3.yml`. It performs the following steps:\n\n1. **Checkout Repository**: Checks out the repository code.\n2. **Install or Update AWS CLI**: Installs or updates the AWS CLI.\n3. **Configure AWS Credentials**: Configures AWS CLI with the necessary credentials and region.\n4. **Login to Amazon ECR**: Logs in to Amazon ECR using the AWS CLI.\n5. **Build Docker Image**: Builds the Docker image using the `Dockerfile`.\n6. **Tag Docker Image**: Tags the Docker image with the appropriate ECR repository URL and tag name.\n7. **Push Docker Image to ECR**: Pushes the tagged Docker image to the specified ECR repository.\n\n```github-actions-workflow\n// filepath: /Users/watchmker/Library/CloudStorage/OneDrive-AmaliTechgGmbH/Amalitech/Labs/aws-micorservice-labs/week4/.github/workflows/upload-to-s3.yml\nname: Build and Push Docker Image\n\non:\n    push:\n        branches:\n            - main\n\njobs:\n    build-and-push:\n        runs-on: ubuntu-latest\n\n        steps:\n            - name: Checkout Repository\n              uses: actions/checkout@v4\n\n            - name: Install or Update AWS CLI\n              run: |\n                  curl \"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip\" -o \"awscliv2.zip\"\n                  unzip awscliv2.zip\n                  sudo ./aws/install --update\n                  aws --version\n\n            - name: Configure AWS Credentials\n              run: |\n                  aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }}\n                  aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}\n                  aws configure set region ${{ secrets.AWS_REGION }}\n\n            - name: Login to Amazon ECR\n              run: |\n                  aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com\n\n            - name: Build Docker Image\n              run: |\n                  docker build -t juliusmarkwei_ecommerce .\n\n            - name: Tag Docker Image\n              run: |\n                  docker tag juliusmarkwei_ecommerce:latest ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/week4lab:juliusmarkwei_ecommerce_api\n\n            - name: Push Docker Image to ECR\n              run: |\n                  docker push ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com/week4lab:juliusmarkwei_ecommerce_api\n```\n\n## How to Use\n\n1. **Clone the Repository**:\n\n    ```sh\n    git clone https://github.com/juliusmarkwei/node-image-ECR.git\n    cd node-image-ECR/\n    ```\n\n2. **Build and Run Locally**:\n\n    ```sh\n    docker build -t juliusmarkwei_ecommerce .\n    docker run -p 3000:3000 juliusmarkwei_ecommerce\n    ```\n\n3. **Push Changes to GitHub**:\n    - Make changes to the code and push to the `main` branch.\n    - The GitHub Actions workflow will automatically build and push the Docker image to ECR.\n\n## Conclusion\n\nThis project demonstrates how to automate the process of building and pushing Docker images to Amazon ECR using GitHub Actions. By following the steps outlined in this README, you can set up a similar workflow for your own projects.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliusmarkwei%2Fnode-image-ecr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliusmarkwei%2Fnode-image-ecr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliusmarkwei%2Fnode-image-ecr/lists"}