The companion-repo for a future AWS partner blog post.
In these first steps we will setup a demo web service, along with scheduled jobs to start and shutdown these services in the morning and evening. This is done for cost saving purposes.
-
Fork the repo and check it out locally.
- This is needed for the pipeline we're going to deploy further down the road. You will need your own repo on github so copilot can create the pipeline for it.
-
Setup a demo webservice
copilot init
- Application name: blogpost-demo
- Workload type: Load Balanced Web Service
- Service name: nyan
- Dockerfile: ./Dockerfile
- Answer "yes" if you're asked if you want a test environment. This will be the one we're using for this demo.
-
Deploy the copilot job which stop the containers in the evening
-
Initialization
copilot job init --name stop-containers
It does not matter which details you configure, they will be dismissed and instead read from the manifest file.
-
Deployment
copilot job deploy --name stop-containers --env test
-
-
Deploy the copilot job which starts the containers in the morning
-
Initialization
copilot job init --name start-containers
It does not matter which details you configure, they will be dismissed and instead read from the manifest file.
-
Deployment
copilot job deploy --name start-containers --env test
-
-
Initialize the pipeline
copilot pipeline init
-
Update the buildspec with the security checks. To add a security check using
hadolint
simply add the following two steps to the generatedcopilot/buildspec.yaml
where it says "Run your tests":docker pull ghcr.io/hadolint/hadolint docker run --rm -i ghcr.io/hadolint/hadolint < Dockerfile
-
Commit and push those changes to your fork
-
Deploy the pipeline
copilot pipeline update
- Activate the github connection when asked
- The pipeline will now already be triggered
-
Verify that the security check has indeed been executed.
- Search for "Run your tests" to find the testing section.
Finally, it's time to clean up the created resources.
copilot job delete
copilot job delete
copilot app delete