I’m a newbie in cloud services and docker.
I have a telegram bot developed with an aiogram library for Python. I can launch it with a command python3.8 app.py. If no errors occur, it will run forever.
Also, I use a simple sqlite3 file as database storage (db.db) that I don’t need to change when I update my source code.
I host my code at Github repository, and I want GCP to automatically update my program when I make a commit to master.
Two questions.
- Is it possible to auto-update a source code without Docker? (I host my program at Google Cloud Platform VM Instance)
- If it’s not, how can I delete the old container from the new one if GCP will only build a new container when I make a commit?
2
Answers
As @guillaume blaquiere mentioned, Google Cloud Build is a good option.
Cloud Build provides a Cloud Build GitHub app that allows you to automatically build your code each time you push a new commit to GitHub.
Take in consideration that the first 120 build-minutes per day are free; you will be charged for builds consumed above this threshold. For more information see the Pricing page and if you’re building using a Dockerfile and storing the built image in Container Registry, you will be charged for storage and the network egress used by your Docker images.
You can see the following guide, that shows how to install Google Cloud Build app and will help you to connect your GitHub repository with your Cloud project and set up continuous integration.
Additionally, I recommend taking a look at the GitHub App triggers, it enables you to automatically invoke builds on Git pushes and pull requests, and view your build results on GitHub and Cloud Console.
I hope you find this information useful.
Github Actions can be used to trigger your CI/CD pipeline. If you are worried about the minutes and storage, you can try host your code in Gitlab.
For your second question. Yes, you can manage your containers by using gcloud command within your CI/CD process. I couldn’t find a direct way to delete old containers, but I think there are some ways you can try:
newly created container image can replace the old images, which
means there will always be one image exist in the registry.
delete all images with old timestamp tag.