about summary refs log tree commit diff
path: root/docker
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-01-28T00·00+0000
committerWilliam Carroll <wpcarro@gmail.com>2020-01-28T00·00+0000
commitbacaa0ca8ad26b4f7ff592746d63d5c6b6c39ab0 (patch)
tree5faad6ce1a7df86b9b86ce5bdd26bcca0a3ede58 /docker
parentaf26b6a1818cf9ee8b4fc9764201556f234202cd (diff)
Add docker/cloud_run.nix
I'm attempting to setup my blog using the following:
- Google Cloud Run: I whitelist a docker image that packages my application and
then Google runs it "statelessly" (i.e. without persistence). The stateless part
should be fine for the time being.
- Nix: Using `<nixpkgs>.dockerTools.buildLayeredImage` to output docker images
from Nix expressions.
- Docker: Upload the output image from the Nix expressions and upload it to
Google Container Registry from which it can be run from Google Cloud Run.

Some helpful commands:

```shell
> sudo gcloud auth login
> nix-build ./docker/cloud_run.nix
> sudo docker image import ./result
> sudo docker tag <name> gcr.io/<google-cloud-project-id>/<name>:<tag>
> sudo docker push gcr.io/<google-cloud-project-id>/<name>:<tag>
```

I'm unsure if Google Cloud Run is my desired end goal, but it may help me
publish a blog faster than setting up a Kubernetes cluster, which is what I'd
ultimately like to do. Cloud Run should be cheaper financially and time-wise.
Diffstat (limited to 'docker')
-rw-r--r--docker/cloud_run.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/docker/cloud_run.nix b/docker/cloud_run.nix
new file mode 100644
index 000000000000..02440df08872
--- /dev/null
+++ b/docker/cloud_run.nix
@@ -0,0 +1,9 @@
+# Attempting to build a Docker image with Nix to run using Google Cloud Run.
+{ pkgs ? import <nixpkgs> {}, ... }:
+
+pkgs.dockerTools.buildLayeredImage {
+  name = "mysql";
+  tag = "latest";
+  config.Cmd = [ "${pkgs.mysql}/bin/mysqld" ];
+  maxLayers = 120;
+}