Skip to content

Instantly share code, notes, and snippets.

View steshaw's full-sized avatar
👨‍💻
Loves programming languages

Steven Shaw steshaw

👨‍💻
Loves programming languages
View GitHub Profile
{
description = "Application packaged using poetry2nix";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
import zipfile
import io
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, mode='w', compression=zipfile.ZIP_DEFLATED) as zipf:
zipf.writestr("file1.txt", "one")
zipf.writestr("file2.txt", "two")
zipf.writestr("file3.txt", "three")
zip_buffer.seek(0)

Docker in Docker on ZFS

Docker in Docker (dind) and overlay2 doesn't currently work on ZFS, so we need to create an ext4 filesystem volume and have Docker use that. This is helpful to anything that requires overlay2 and/or dind such as minikube (with Docker driver), or K3s.

sudo zfs create -s -V 100G rpool/docker
sudo mkfs.ext4 /dev/rpool/docker
$ curl -sfL https://get.k3s.io | sh -
[INFO]  Finding release for channel stable
[INFO]  Using v1.25.7+k3s1 as release
[INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.25.7+k3s1/sha256sum-amd64.txt
[INFO]  Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.25.7+k3s1/k3s
[INFO]  Verifying binary download
[INFO]  Installing k3s to /usr/local/bin/k3s
[INFO]  Skipping installation of SELinux RPM
[INFO]  Creating /usr/local/bin/kubectl symlink to k3s
@steshaw
steshaw / ubuntu-setup.md
Last active March 21, 2023 01:18
Ubuntu desktop setup

Setting up a fresh Ubuntu machine

Start with Ubuntu

Install Ubuntu Desktop 22.04, encrypted ZFS, with minimal packages.

Install OpenSSH

We may want to do the rest of the installation/configuration from our laptop over ssh, so:

@steshaw
steshaw / run-1.md
Last active March 18, 2023 00:14
Chainsail container image build times

First run

Very first run on freshly installed machine.

Total elapsed time: 18m22s

  • chainsail-celery-worker 194.0s
  • chainsail-scheduler 63.6s
  • chainsail-nginx 31.8s
  • chainsail-user-code 237.0s
#!/usr/bin/env bash
set -euo pipefail
base_image='registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb10'
tag='9e4c540d9e4972a36291dfdf81f079f37d748890'
image="${base_image}:${tag}"
docker run -it --rm \
--volume /nix:/nix \
{-# language DataKinds #-}
{-# language DuplicateRecordFields #-}
{-# language OverloadedRecordDot #-}
import GHC.Records
data Person = Person
{ name :: String
, pet :: Pet
, partner :: Maybe Person