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

fix: migrate to docker-build prvider #178

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 37 additions & 8 deletions packages/untp-playground/infra/infra/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as aws from '@pulumi/aws';
import * as awsx from '@pulumi/awsx';
import * as pulumi from '@pulumi/pulumi';

import * as docker_build from "@pulumi/docker-build";

export function deployApp(){

Expand Down Expand Up @@ -110,17 +110,46 @@ const lb = new awsx.lb.ApplicationLoadBalancer(

const cluster = new aws.ecs.Cluster(`app-cluster-${stack}`);

const appRepository = new awsx.ecr.Repository(`app-ecr-${stack}`);
const appRepository = new aws.ecr.Repository(`app-ecr-${stack}`);
const authToken = aws.ecr.getAuthorizationTokenOutput({
registryId: appRepository.registryId,
});

const appImage = new awsx.ecr.Image(`app-image-${stack}`, {
repositoryUrl: appRepository.url,
platform: 'linux/amd64',
context: '../',
args: {
const appImage = new docker_build.Image(`app-image-${stack}`, {
// Tag our image with our ECR repository's address.
tags: [pulumi.interpolate`${appRepository.repositoryUrl}:latest`],
/* dockerfile: {
location: '../../../packages/untp-playground/Dockerfile',
}, */
context: {
location: '../',
},
// Use the pushed image as a cache source.
cacheFrom: [{
registry: {
ref: pulumi.interpolate`${appRepository.repositoryUrl}:latest`,
},
}],
// Include an inline cache with our pushed image.
cacheTo: [{
inline: {},
}],
platforms: [
"linux/amd64",
],
buildArgs: {
...(process.env.NEXT_PUBLIC_BASE_PATH && { NEXT_PUBLIC_BASE_PATH: process.env.NEXT_PUBLIC_BASE_PATH }),
...(process.env.NEXT_PUBLIC_ASSET_PREFIX && { NEXT_PUBLIC_ASSET_PREFIX: process.env.NEXT_PUBLIC_ASSET_PREFIX }),
...(process.env.NEXT_PUBLIC_IMAGE_PATH && { NEXT_PUBLIC_IMAGE_PATH: process.env.NEXT_PUBLIC_IMAGE_PATH }),
},
// Push the final result to ECR.
push: true,
// Provide our ECR credentials.
registries: [{
address: appRepository.repositoryUrl,
password: authToken.password,
username: authToken.userName,
}],
});

const service = new awsx.ecs.FargateService(
Expand All @@ -131,7 +160,7 @@ const service = new awsx.ecs.FargateService(
taskDefinitionArgs: {
container: {
name: `app-${stack}`,
image: appImage.imageUri,
image: appImage.ref,
cpu: 128,
memory: 512,
essential: true,
Expand Down
3 changes: 2 additions & 1 deletion packages/untp-playground/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"@pulumi/aws": "^6.0.0",
"@pulumi/awsx": "^2.0.2",
"@pulumi/pulumi": "^3.113.0"
"@pulumi/pulumi": "^3.113.0",
"@pulumi/docker-build": "^0.0.7"
}
}
Loading