Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create aws.yml #48

Merged
merged 55 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f0bcbf7
Create aws.yml
conorheffron Sep 8, 2024
8de778a
Update aws.yml
conorheffron Sep 8, 2024
5eeb959
Create .aws.task-definition.json
conorheffron Sep 8, 2024
240a7ad
Update aws.yml
conorheffron Sep 8, 2024
3e6ac9e
Update aws.yml
conorheffron Sep 8, 2024
536104b
Update aws.yml
conorheffron Sep 8, 2024
8290b9b
mv task definition JSON
conorheffron Sep 8, 2024
b4dccd3
Update aws.yml
conorheffron Sep 8, 2024
38bd298
mv task def
conorheffron Sep 8, 2024
52ea949
rename task def
conorheffron Sep 8, 2024
52b44b8
Update task-definition.json
conorheffron Sep 8, 2024
2f02cb7
Update task-definition.json
conorheffron Sep 8, 2024
7274384
Update aws.yml & task-definition.json
conorheffron Sep 8, 2024
fc68a40
Update aws.yml
conorheffron Sep 8, 2024
c0d7ff3
Update Dockerfile
conorheffron Sep 8, 2024
7d12e83
Update task-definition.json
conorheffron Sep 8, 2024
9076dc6
Update task-definition.json
conorheffron Sep 8, 2024
9e2a2da
Update aws.yml
conorheffron Sep 8, 2024
5a8296b
Update aws.yml
conorheffron Sep 8, 2024
29bfe93
Update Dockerfile
conorheffron Sep 8, 2024
ea47824
Update aws.yml & task-definition.json
conorheffron Sep 8, 2024
52595ad
Update aws.yml & task-definition.json
conorheffron Sep 8, 2024
93a45d1
Update aws.yml & task-definition.json
conorheffron Sep 8, 2024
3f93d7f
Update aws.yml & task-definition.json
conorheffron Sep 8, 2024
48142e4
Update task-definition.json
conorheffron Sep 8, 2024
a3206fa
Update Dockerfile & task-definition.json
conorheffron Sep 8, 2024
e301bec
Update Dockerfile & task-definition.json
conorheffron Sep 8, 2024
382da42
Update Dockerfile & task-definition.json
conorheffron Sep 8, 2024
71af9e5
Update task-definition.json
conorheffron Sep 8, 2024
5a524c4
Update aws.yml
conorheffron Sep 8, 2024
bc5bb3c
Update aws.yml
conorheffron Sep 8, 2024
c484c51
Attempt new conf
conorheffron Sep 8, 2024
ad1582e
Attempt conf fix
conorheffron Sep 8, 2024
fe427c3
Revert changes
conorheffron Sep 8, 2024
2fad757
Update task-definition.json
conorheffron Sep 8, 2024
6704602
Update task-definition.json
conorheffron Sep 8, 2024
05a8da7
Update task-definition.json
conorheffron Sep 8, 2024
d0a077b
Update run.sh & Dockerfile
conorheffron Sep 8, 2024
b8b0c77
Update run.sh & Dockerfile
conorheffron Sep 8, 2024
529fa76
Update Dockerfile
conorheffron Sep 8, 2024
f3494dc
Update run.sh & Dockerfile
conorheffron Sep 8, 2024
2970b21
Update Dockerfile
conorheffron Sep 8, 2024
55b5f48
Update Dockerfile, aws.yml & docker-image.yml
conorheffron Sep 8, 2024
9b50bc9
Update Dockerfile
conorheffron Sep 8, 2024
7b419b2
Update Dockerfile
conorheffron Sep 8, 2024
7c3820d
Update prot references
conorheffron Sep 8, 2024
846dcec
Update .aws/task-definition.json
conorheffron Sep 8, 2024
776671e
Update task-definition.json
conorheffron Sep 8, 2024
b0561d5
Update task-definition.json
conorheffron Sep 9, 2024
c0c45a0
Update ports
conorheffron Sep 9, 2024
8928c11
Update .aws/task-definition.json
conorheffron Sep 9, 2024
01619fc
Update port refs
conorheffron Sep 9, 2024
7247a7b
Update Dockerfile
conorheffron Sep 9, 2024
f1f7811
Merge remote-tracking branch 'origin/main' into doc-ec2
conorheffron Sep 9, 2024
0bf050f
Update aws.yml & README.md
conorheffron Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .aws/task-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"taskDefinitionArn": "arn:aws:ecs:eu-north-1:345594590074:task-definition/ironoc:latest",
"containerDefinitions": [
{
"name": "ironoc",
"image": "345594590074.dkr.ecr.eu-north-1.amazonaws.com/conorheffron/ironoc:latest",
"memory": "512",
"portMappings": [
{
"name": "ironoc-80-tcp",
"containerPort": 8080,
"hostPort": 80,
"protocol": "tcp",
"appProtocol": "http"
}
],
"essential": true,
"environment": [],
"mountPoints": [],
"volumesFrom": [],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/ironoc",
"mode": "non-blocking",
"awslogs-create-group": "true",
"max-buffer-size": "25m",
"awslogs-region": "eu-north-1",
"awslogs-stream-prefix": "ecs"
}
},
"systemControls": []
}
],
"family": "ironoc",
"taskRoleArn": "arn:aws:iam::345594590074:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::345594590074:role/ecsTaskExecutionRole",
"networkMode": "bridge",
"volumes": [],
"status": "ACTIVE",
"requiresAttributes": [
{
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
},
{
"name": "ecs.capability.execution-role-awslogs"
},
{
"name": "com.amazonaws.ecs.capability.ecr-auth"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.28"
},
{
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"name": "ecs.capability.execution-role-ecr-pull"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
},
{
"name": "ecs.capability.task-eni"
},
{
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.29"
}
],
"placementConstraints": [],
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"EC2"
],
"cpu": null,
"memory": null,
"runtimePlatform": {
"cpuArchitecture": "X86_64",
"operatingSystemFamily": "LINUX"
},
"registeredAt": "2024-09-08T21:13:30.158Z",
"registeredBy": "arn:aws:iam::345594590074:root",
"tags": []
}
75 changes: 75 additions & 0 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deploy to Amazon ECS

on:
push:
branches: [ "main" ]

env:
AWS_REGION: eu-north-1
ECR_REPOSITORY: conorheffron/ironoc
ECS_SERVICE: IronocService
ECS_CLUSTER: IronocPortfolioCluster
ECS_TASK_DEFINITION: .aws/task-definition.json
CONTAINER_NAME: ironoc

permissions:
contents: read

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
18 changes: 0 additions & 18 deletions .github/workflows/docker-image.yml

This file was deleted.

12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
FROM eclipse-temurin:21-jdk

VOLUME /tmp
#for local
#ADD target/*.war app.war
#for CI/CD
ADD *.war app.war

COPY target/*.war app.war
RUN sh -c 'touch /app.war'

ENV RUN_FILE /run.sh
ADD run.sh ${RUN_FILE}
COPY run.sh ${RUN_FILE}
RUN chmod +x ${RUN_FILE}

ENTRYPOINT [ "sh", "-c", "${RUN_FILE}" ]
EXPOSE 8080

ENTRYPOINT [ "sh", "-c", "${RUN_FILE}" ]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

![Auto Assign](https://github.com/conorheffron/ironoc/actions/workflows/auto-assign.yml/badge.svg)

[![Deploy to Amazon ECS](https://github.com/conorheffron/ironoc/actions/workflows/aws.yml/badge.svg)](https://github.com/conorheffron/ironoc/actions/workflows/aws.yml)

# Docker Image
[ironoc Docker Hub Link](https://hub.docker.com/repository/docker/conorheffron/ironoc/general)

Expand All @@ -14,7 +16,7 @@
Personal website / portfolio http://www.ironoc.com/ (no longer hosted)

# Tech Stack
Java 21 (LTS), Spring Boot 3.3, Maven 3.8, HTML5+CSS, JQuery, Docker / Bash
Java 21 (LTS), Spring Boot 3.3, Maven 3.8, HTML5+CSS, JQuery, Docker / Bash, AWS

# Run without cloning project:
```
Expand Down
Loading