惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
S
Secure Thoughts
I
Intezer
Project Zero
Project Zero
Stack Overflow Blog
Stack Overflow Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
F
Full Disclosure
P
Proofpoint News Feed
T
The Exploit Database - CXSecurity.com
人人都是产品经理
人人都是产品经理
博客园_首页
J
Java Code Geeks
Recorded Future
Recorded Future
K
Kaspersky official blog
GbyAI
GbyAI
S
Schneier on Security
The Cloudflare Blog
Spread Privacy
Spread Privacy
C
Cisco Blogs
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
爱范儿
爱范儿
Microsoft Azure Blog
Microsoft Azure Blog
Know Your Adversary
Know Your Adversary
T
Tenable Blog
A
Arctic Wolf
Blog — PlanetScale
Blog — PlanetScale
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
O
OpenAI News
Last Week in AI
Last Week in AI
B
Blog RSS Feed
T
Troy Hunt's Blog
G
GRAHAM CLULEY
N
Netflix TechBlog - Medium
Vercel News
Vercel News
量子位
The Register - Security
The Register - Security
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
U
Unit 42
Security Archives - TechRepublic
Security Archives - TechRepublic
C
Cyber Attacks, Cyber Crime and Cyber Security
N
News and Events Feed by Topic

ashishb.net

A day in Luxembourg - the richest country in the world I was asked to install malware during a fake interview Book summary: Breakneck - China's quest to engineer the future by Dan Wang Book summary: How to Teach Your Baby to Read Book Summary: The Discontented Little Baby Book by Pamela Douglas Introducing Amazing Sandbox - run third-party tools and AI agents securely on your machine Why software outsourcing gets a bad reputation? Book summary: The Natural Baby Sleep Solution by Polly Moore A day in Antwerp, Belgium Journey of online influencers Two days in Brussels, Belgium Shortcuts - when we love them and when we don't A visit to Rakhigarhi Three days in overhyped Paris Empty Japan, crowded Tokyo The real lock-in in GitHub is not the code, but the stars 11-day Norwegian Breakaway East Caribbean cruise Sanskrit and Sri Lankan Air Force Use REST with Open API The Achilles heel of American capitalism Costa Rica in 4 days At a juice stall in Sri Lanka A short stay at Warsaw, Poland Best practices for using Python & uv inside Docker Two days in Vilnius, Lithuania How IntelliJ IDEs waste disk space Pregnancy Why there aren't many digital nomads from India Two days in Riga, Latvia To keep your machine secure, run third-party tools inside Docker Family Ties in Your DNA: Some relatives are closer than others Doctors per capita Two days in Tallinn, Estonia Ship tools as standalone static binaries Made in America Two days in Helsinki, Finland Maintaining an Android app is a lot of work The land of good deals Two days in Oslo, Norway FastAPI vs Flask performance comparison Google Search is losing to Perplexity Two days in Dublin, Ireland Continuous integration ≠ Continuous delivery World's simplest project success heuristic London in 5 days It is hard to recommend Python in production Inflation, IRS, Credit cards, and Vendors Temu and the Chinese approach Things to do in Miami Florida Revenue vs Cost Axis Language learning as an adult The unanchored babies of the green card limbo Price variance in the United States A day in Louisville, Kentucky A surprisingly positive experience with Air India Unhospitable Airports Android: Don't use stale views USA = Union of Sales and Advertisement A day in Nashville, Tennessee Minimize Javascript in your codebase A day in Birmingham, Alabama In defense of ad-supported products Real vs artificial world The science behind Punjabi singers Hiking Mt. Fuji The Indian startup bubble is insane Repairing database on the fly for millions of users Book Summary: One up on Wall Street by Peter Lynch It is hard to recommend Google Cloud At the Prague airport Kyoto in three days Migrating from WordPress to Hugo Book summary: Sick Societies by Robert B. Edgerton Statistical outcomes require statistical games Illegal immigrants to Europe via Cairo Tokyo in three days Mobs are Status Games Writing Script matters as much as the spoken language Sri Lanka in 5 days LLMs: great for business but bad business Book Summary: Safe Haven by Mark Spitznagel Mac shortcut for typing Avagraha symbol On a bus with an asylum seeker Nicaragua in 5 days When to commit Generated code to version control Why I always buy a local SIM in a foreign country Use Makefile for Android Four days in Guadalajara, Mexico Android Navigation: Up vs Back Hotels vs Airbnb vs Hostels Currency issues in Argentina Abstractions should be deep not wide Some data on podcasting Always support compressed response in an API service A day in El Calafate - Patagonia, Argentina Hermetic docker images with Hugging Face machine learning models American Elections The sound of "ch" API services should always have usage Limits Hiking in El Chaltén - trekking capital of Argentina
How to deploy side projects as web services for free
Ashish Bhatia · 2020-04-19 · via ashishb.net

In 2020, the web is still the most accessible permission-less platform. For the past few months, I have been playing and building side projects to simplify my life. I started with DeckSaver for downloading decks from Docsend, AutoSnoozer for email management, and StayInTouch for maintaining follow-ups.

When I started on this journey, I had the following in my mind.

  1. Cost of domain ~ 12$ a year or 1$ a month
  2. Cost of a VM ~ 10$ a month

And this is excluding maintenance efforts like TLS certificate renewal, server uptime, etc. I quickly realized that this isn’t sustainable. A single project would cost ~150$ a year to run. Add a few more side-projects, and this will be a costly hobby.

To avoid the domain costs, I deploy almost all of my side-projects as a subdomain of my existing domain ashishb.net.

For compute and storage, I looked for alternatives. Few alternatives like Firebase Cloud Functions or AWS Lambda look great on the surface, but there is a considerable lock-in involved. Searching further, I found Google Cloud Run (see also my later post on why Google Cloud is hard to recommend). It has zero base cost and zero lock-ins since it runs docker images and minimal configuration work. Cloud Run is serverless. The service deals with the task of getting and automatically renewing TLS certificates as well as scaling instances based on the demand. You get StackDriver logging for free. As there are no VMs, I can’t SSH into the machine and make changes, which is excellent from a security perspective since there is no chance of someone compromising and running services on it. I have to upload Docker images, so I get an added discipline of building fully portable docker images, which, if required, can be moved elsewhere with zero portability cost. Now, docker images are stateless, so, for storing data, I could have either used Google Cloud SQL or Google Cloud Storage (the equivalent of Amazon S3). The base cost of Cloud SQL is high ~20-30$ month, while it is zero for Cloud Storage. So, my current architecture consists of Google Cloud Run + Google Cloud Storage. Now, since Google Cloud Run keeps these Docker containers on standby, keep the container image size small to ensure quick bootups (cold starts).

Persistence and Secrets on Google Cloud Run

There are two issues to consider when deploying docker images. One is persistence, and the second is credentials (secrets). I like the zero base price of Google Cloud Storage (GCS), and that’s why it is my favorite for persistence. For storing credentials, say GCS read/write credentials, it is best not to store the keys in the docker image itself. The way I prefer to do is to pass them via Environment variables at the time of deployment. An even better approach for projects with multiple contributors is to use Secret Manager.

I mostly write in Go. I think it is a perfect language for building web services. That fact isn’t surprising when one realizes that it came out of Google, a company initially built around web services. I templated out my setup for faster iteration. It’s open-sourced at https://github.com/ashishb/golang-template-repo.

Deployment

To deploy to Google cloud run, first install gcloud CLI and do a one-time configuration.

1
2
$ gcloud auth configure-docker
...

Now push your image to Google Container Register. If your project ID is first_gcloud_project-67 and the service name is hello_world then the tag name has to be gcr.io/first_gcloud_project/hello_world:main

1
2
$ docker push gcr.io/first_gcloud_project-67/hello_world:main
...

Now, start your binary.

1
2
3
4
5
6
$ gcloud run deploy hello_world \
        --image gcr.io/first_gcloud_project-67/hello_world:main \
        --platform managed \
        --region us-central1 \
        --set-env-vars=SECRET_VALUE="secret" \
        --project first_gcloud_project-67

And your service is ready to be accessed. You can see the deployed URL from https://console.cloud.google.com/run?project= first_gcloud_project

Now, the service would be accessible at an unmemorizable .app domain. I would recommend mapping a more memorizable custom domain you own to the same service.

I have abstracted out all these steps and the ones mentioned in the previous blogpost into a single template repository.

  1. Clone the repo git clone https://github.com/ashishb/golang-template-repo
  2. Fill in GOOGLE_CLOUD_PROJECT_ID and GOOGLE_CLOUD_RUN_SERVICE_NAME
  3. And deploy it using make gcloud_deploy