Skip to content

Commit

Permalink
fix: use a mock docker image when test and cdk-diff is executed
Browse files Browse the repository at this point in the history
  • Loading branch information
yutaro-sakamoto committed Nov 28, 2024
1 parent 840cf95 commit 690b550
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/post-cdk-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
ROLE_ARN: arn:aws:iam::${{ secrets.AWS_ID }}:role/${{ secrets.ROLE_NAME }}
SESSION_NAME: gh-oidc-${{ github.run_id }}-${{ github.run_attempt }}
AWS_CLIENT_VPN_CERTIFICATE_ARN: ${{ secrets.AWS_CLIENT_VPN_CERTIFICATE_ARN }}
USE_MOCK_DOCKER_IMAGE: "true"

jobs:
cdk-diff:
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,21 @@ permissions:

env:
AWS_CLIENT_VPN_CERTIFICATE_ARN: ${{ secrets.AWS_CLIENT_VPN_CERTIFICATE_ARN }}
USE_MOCK_DOCKER_IMAGE: "true"

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
cache-dependency-path: "infrastructure/package-lock.json"

- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"

- name: Build a Docker image
working-directory: ./server
run: ./gradlew buildDockerImageTarball

- run: npm ci
working-directory: ./infrastructure

Expand Down
7 changes: 6 additions & 1 deletion infrastructure/lib/constructs/ECS/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,19 @@ export class ECS extends Construct {
"../../../../server/app/cobol4j-aws-web.tar",
);

const image =
process.env.USE_MOCK_DOCKER_IMAGE === "true"
? ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample")
: ecs.ContainerImage.fromTarball(tarballPath);

// Fargateサービスを作成
const albEcsService = new ApplicationLoadBalancedFargateService(
this,
"Service",
{
cluster,
taskImageOptions: {
image: ecs.ContainerImage.fromTarball(tarballPath),
image: image,
containerPort: 8080,
},
assignPublicIp: true,
Expand Down

0 comments on commit 690b550

Please sign in to comment.