Push to ECR with github actions

This commit is contained in:
NkambuleTech 2025-02-22 17:38:53 +02:00
parent aae8bbdb35
commit 4ffd2ad012
3 changed files with 2282 additions and 0 deletions

49
.github/deploy.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: Deploy to ECR
on:
push:
branches: [ main ]
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::658817016946:role/GijiDeploy-Role-HuJyYropIfWb
aws-region: af-south-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: dfs
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f buildScripts/Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Deploy to AWS ECS
env:
ECS_CLUSTER: DailyFitnessCluster
ECS_SERVICE: DFS-01
run: |
aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment

27
buildScripts/Dockerfile Normal file
View File

@ -0,0 +1,27 @@
# Use a lightweight Node.js image
FROM node:16-alpine as build-stage
# Set the working directory
WORKDIR /app
# Copy package.json and install dependencies
COPY package*.json ./
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the Vue.js app
RUN npm run build
# Use a lightweight Nginx image to serve the app
FROM nginx:alpine as production-stage
# Copy the built app from the build stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]

2206
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff