Skip to content

Instantly share code, notes, and snippets.

View JT501's full-sized avatar
🚀

Johnny Tsoi JT501

🚀
View GitHub Profile
@JT501
JT501 / docker-no-permissions-tmp.md
Last active August 31, 2023 17:53
Docker container: Permission denied to /tmp after server reboot

It looks like it is a bug of latest version Google COS Google, Container-Optimized OS, 105-17412.156.30 LTS, Kernel: COS-5.15.120 Kubernetes: 1.25.5 Docker: 23.0.3 Family: cos-105-lts.

VM using older version has no issues.


Workaround

  1. Create Dockerfile with command RUN chmod 777 /tmp
  2. Shut down all affected container by docker-compose down
  3. Remove all the unused images by docker image prune -a
  4. Clear all the cache bu docker system prune
  5. Turn on the containers by docker-compose up -d, it will rebuild all the needed image and set correct permission to /tmp.
@JT501
JT501 / firebase-config.md
Last active October 12, 2021 10:13
Firebase Functions Config

Import json to functions config

firebase functions:config:set env="$(cat functions.config.json)"

Get the json

firebase functions:config:get env
@JT501
JT501 / 1-Laravel-Docker-SSL.md
Last active May 2, 2024 16:25
Laravel + nginx-proxy + docker-letsencrypt-nginx-proxy-companion

Laravel + nginx-proxy + acme-companion

(Updated on 7/8/2023)

Deploy Laravel on Docker using nginx-proxy + acme-companion (formerly called docker-letsencrypt-nginx-proxy-companion)

  1. Prepare two seperate docker compose file i.e docker-compose.nginx.yml & docker-compose.app.yml

  2. Create nginx directory and move docker-compose.nginx.yml into it.

  3. Create YOUR_DOMAIN.conf and YOUR_DOMAIN_location_override.conf in nginx directory.

@JT501
JT501 / cp_gce_gcs.md
Last active December 15, 2020 16:00
Copy files from GCE VM to GCS

1. Login gcloud

gcloud auth login

Login with your project account

2. Copy files / directory

gsutil -m cp -r -a public-read dir/ gs://bucket/uploads
@JT501
JT501 / docker-compose-gcr-gar.md
Last active January 17, 2024 06:16
Run docker-compose on Container Optimized OS (GCE) with access to GCR & GAR

docker-compose on Container Optimized OS (GCE) with access to GCR & GAR

For Docker Compose V2.0, please read the comment below.

Docker Compose V1.0

Since GCE's Container-Optimized OS do not include docker-compose by default. So, we need to use the official docker/compose image as a workaround. However, docker/compose cannot access GCR or GAR to pull private images. Therefore we have to create a custom docker-compose image which is authenticated to GCR / GAR.

@JT501
JT501 / gcloud-ssl-error.md
Last active November 24, 2020 07:19
ERROR: gcloud failed to load: /xxx/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by xxx)

ERROR: gcloud failed to load: /xxx/libssl.so.1.1: version `OPENSSL_1_1_1' not found (required by xxx)

export LD_LIBRARY_PATH=/usr/local/lib
@JT501
JT501 / GCE Docker.md
Last active November 25, 2020 10:14
Docker Config in GCE and using GCR

Docker Config in GCE and using GAR

2. Add user into docker group:

sudo usermod -a -G docker ${USER}

3. Add a service account in Google Cloud Console

  • IAM & Admin -> Service Accounts -> Create service account
@JT501
JT501 / useCountDown.ts
Last active July 18, 2023 04:25
React useCountDown Hook
import { useEffect, useRef, useState } from 'react';
export const useCountDown: (
total: number,
ms?: number,
) => [number, () => void, () => void, () => void] = (
total: number,
ms: number = 1000,
) => {
const [counter, setCountDown] = useState(total);
@JT501
JT501 / DelayRedirect.tsx
Created October 17, 2020 09:53
React Router - DelayRedirect
import * as React from 'react';
import { useEffect, useState } from 'react';
import { Redirect, RedirectProps } from 'react-router';
interface DelayProps {
delay: number;
}
const DelayRedirect = ({ delay, ...rest }: RedirectProps & DelayProps) => {
const [timeToRedirect, setTimeToRedirect] = useState(false);
@JT501
JT501 / BaseNavigationController.swift
Last active November 16, 2019 08:32
Add Back Default Swipe Back Gesture & Transition
//
// BaseNavigationController.swift
// Mention
//
// Created by Johnny Choi on 21/10/2019.
// Copyright (c) 2019 Johnny@Co-fire.com. All rights reserved.
//
import UIKit