Service
INSTRUCTIONS TO USE THIS SERVICE (Delete this section after completing and evaluating that it works)
tldr: change to whatever your service is wherever you see it (e.g. question)
- Update the
/infra
directory- Copy paste this entire directory and rename it to your service name (e.g. questions-service)
- Update the README file wherever you see the
<TEMPLATE>
placeholder - Update the
/infra/Pulumi.yaml
file wherever you see the<TEMPLATE>
placeholder - Update the
/infra/Pulumi.staging.yaml
file wherever you see thetemplate
placeholder - Update the
/infra/Pulumi.prod.yaml
file wherever you see thetemplate
placeholder - Update the
/infra/package.json
file wherever you see thetemplate
placeholder - Update the
/infra/index.ts
file wherever you see thetemplate
placeholder
- Update the
/app
directory- Modify the
/app
directory as you need for your application (even if it is not in TypeScript) - If staying in TypeScript, update the
/app/package.json
file wherever you see thetemplate
placeholder - Ensure that you have a
Dockerfile
for deployment and aDockerfile.dev
used for dev
- Modify the
- Create your Pulumi stacks
- In your
/infra
directory, runpulumi stack init staging
to create the staging stack - In your
/infra
directory, runpulumi stack init prod
to create the prod stack - Run
pulumi stack ls
to verify that you have created your 2 stacks (the URL should behttps://app.pulumi.com/cs3219/<TEMPLATE>-service-infra/<STACK_NAME>
)
- In your
- Update your Pulumi stack config's secrets
- This has to be done because secrets created via the Pulumi stack are per-stack and cannot be copied ver
- Ensure you are in the
/infra
directory - First, select the
staging
stack by runningpulumi stack select staging
- Then update the config by running
pulumi config set-all --secret acmEcsCertificateArn=[SECRET_VALUE] --secret hostedZoneId=[SECRET_VALUE]
(For the secret values, please refer to the team's vault) - Then, repeat steps 3 and 4 with the
prod
stack
- Update the
docker-compose.yml
at the root of the project- Copy the
template-service
service and rename it to your service name (e.g. questions-service) - If you are not using TypeScript, modify it as needed
- Change the port host port (the value BEFORE the
:
) to the agreed upon port for your service
- Copy the
- Create your GitHub workflows
- Copy the
.github/workflows/template_service_pull_request.yml
file and rename it to your service name (e.g.question_service_pull_request.yml
) and update all thetemplate
placeholders - Copy the
.github/workflows/template_service_push.yml
file and rename it to your service name (e.g.question_service_push.yml
) and update all thetemplate
placeholders
- Copy the
- Verify that everything is working properly
- You should be able to run your app alone without Docker (e.g. using
npm run dev
for a TypeScript project) - You should be able to run your app alongside all the other services using the project root's
docker-compose
by runningdocker-compose up
(If you encounter any issues with dependencies missing, rundocker-compose down
and thendocker-compose up --build
) - When you push your code to GitHub, the GitHub workflow should run and deploy your service to the staging environment
- You should be able to run your app alone without Docker (e.g. using
** Note: Your /app
directory code does not need to be in TypeScript - your Dockerfile just needs to be working**
Instructions to run
- Please refer to the README.md in the root of the project for instructions to run the service
New environment variables
If you need to add new environment variables, please add them to the following locations:
-
/backend/<TEMPLATE>-service/app/.env.example
file and commit it. For others to run the service locally.- If the value is a secret, leave it blank and store it with the team's vault (e.g. an API key, secret key, access token, ARN, etc.)
- If the value is not a secret, you can leave in the value in the
.env.example
file (e.g. http://localhost:8000, staging, 32, etc.)
-
/backend/<TEMPLATE>-service/infra/index.ts
under theDeploy an ECS Service on Fargate to host the application container
comment under theenv
object. For Pulumi to inject the appropriate environment variables during deployment.
-