wonderful-analyst-83325
03/06/2025, 7:21 AMwonderful-analyst-83325
03/06/2025, 7:30 AMimport * as gcp from '@pulumi/gcp';
import * as pulumi from '@pulumi/pulumi';
import * as docker from '@pulumi/docker';
import { dbInstance, dbUser, dbPassword, db } from './database';
import { backendenvs } from './backend-envs';
import { appName, region } from './constants';
import { bucket, cdnURL } from './storage';
// Backend API (NestJS) Cloud Run Service
const imageName = `${appName}-backend-app`;
const image = new docker.Image(`${appName}-backend-image`, {
imageName: pulumi.interpolate`gcr.io/${gcp.config.project}/${imageName}:${new Date().getTime()}`,
build: {
context: '..',
platform: 'linux/amd64',
},
});
export const backendService = new gcp.cloudrun.Service('backend-service', {
location: region,
template: {
spec: {
containers: [
{
image: image.imageName,
ports: [{ containerPort: 3000 }],
envs: [
...backendenvs,
{
name: 'DB_HOST',
value: dbInstance.publicIpAddress,
},
{ name: 'DB_PORT', value: '5432' },
{ name: 'DB_USERNAME', value: dbUser.name },
{ name: 'DB_PASSWORD', value: dbPassword.result },
{ name: 'DB_NAME', value: db.name },
{ name: 'GCP_PROJECT_ID', value: gcp.config.project },
{ name: 'GCP_STORAGE_BUCKET', value: bucket.name },
{
name: 'GCP_KEY_FILENAME',
value: './assets/certs/ehs-serv-acc.json',
},
{
name: 'GCP_CDN_HOSTNAME',
value: cdnURL,
},
{
name: 'VIDEO_PROCESSING_API_URL',
value:
'<https://video-processing-service-b6823df-oflw6k6npa-uc.a.run.app>',
},
{
name: 'FIREBASE_ANALYTICS_SERVICE_ACCOUNT',
value: './assets/certs/ehs-serv-acc.json',
},
{
name: 'FIREBASE_ANALYTICS_PROPERTY_ID',
value: '449999167',
},
],
resources: {
limits: {
cpu: '1',
memory: '4Gi',
},
},
},
],
containerConcurrency: 80,
},
},
traffics: [{ percent: 100, latestRevision: true }],
});
new gcp.cloudrun.IamMember('backend-service-iam', {
service: backendService.name,
location: region,
role: 'roles/run.invoker',
member: 'allUsers',
});
this is the code responsible for the docker imageNo matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by