Skip to content

Instantly share code, notes, and snippets.

View kai-phan's full-sized avatar
👋
Hi there!

Vinh Quy Phan kai-phan

👋
Hi there!
View GitHub Profile
@kai-phan
kai-phan / Experimental Docker structure.md
Created October 25, 2024 13:13 — forked from shinsenter/Experimental Docker structure.md
Docker structure for deploying to multiple environments

Beginning

There are many approaches to implementing a reuse of a common preset for Docker services for multiple environments, such as production and local environments.

This makes it possible to ensure the highest consistency for different environments with the same code-base. Implementing reuse of docker compose options also makes it easier to manage them.

I found on github a project called serversideup/spin. They took an approach using a feature called Docker overrides, to change some properties of common services for different environments.

After reading through their documentation, I realized that there are a few real-life cases where this project can not implement (or is difficult to archive).

Run a local HTTP server with Docker 🐳

Serve your static website from localhost using Docker and Nginx.

By @arrested-developer

Why Docker?

Do you know the famous phrase "it works on my machine"?

@kai-phan
kai-phan / default
Created October 2, 2024 17:41 — forked from dtomasi/default
Brew Nginx PHP7
server {
listen 80;
server_name localhost;
root /Users/YOUR_USERNAME/Sites;
access_log /Library/Logs/default.access.log main;
location / {
include /usr/local/etc/nginx/conf.d/php-fpm;
}
@kai-phan
kai-phan / gist.md
Created April 11, 2024 08:50 — forked from ArcRanges/gist.md
aws-ec2-nextjs

Instructions to properly set up a production-ready NextJS App with AWS

This is a summary of how to start your own NextJS app, create the repo on Github, upload later in an AWS EC2 Instance and automate the process with AWS Codebuild, CodeDeploy, & CodePipeline.

After following these instructions you should be able to:

  • Create a NextJS App
  • Create an AWS EC2 instance
  • Be able to SSH to an EC2 instance
  • Prepare the instance as a Node environment
  • Configure Nginx service for proper routing
  • Configure domain and add SSL
@kai-phan
kai-phan / main.yaml
Created December 10, 2023 05:41
Github Action work flow static site with Vite and AWS
name: Vite with AWS
on:
push:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
@kai-phan
kai-phan / index.ts
Last active October 7, 2023 12:52
Assign a local variable in a type-level expression!
type Fn<I> = SuperHeavyComputation<I> extends infer Result
// ^ 🤯 ^
? [Result, Result, Result]
: never; // this branch can never be reached
// We can use infer directly after extends.
// This will have the effect of assigning the result of SuperHeavyComputation<I> to a variable.
// The downside is that we need to declare an "else" code branch even though we know it will never be reached because any type is assignable to infer Result.
@kai-phan
kai-phan / router.config.tsx
Last active July 19, 2023 12:33
Type safe useNavigate hook for React router 6.x
import {
Outlet,
createBrowserRouter,
useNavigate,
NavigateOptions,
} from 'react-router-dom';
const routeObjects = [
{
path: '/',