Skip to content

Instantly share code, notes, and snippets.

View liemle3893's full-sized avatar

Liem Le Hoang Duc liemle3893

View GitHub Profile
@liemle3893
liemle3893 / .gitlab-ci.yml
Created April 1, 2020 12:27
Gitlab CI with Nomad
# Disable the Gradle daemon for Continuous Integration servers as correctness
# is usually a priority over speed in CI environments. Using a fresh
# runtime for each build is more reliable since the runtime is completely
# isolated from any previous builds.
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
DOCKER_TLS_CERTDIR: ""
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
@liemle3893
liemle3893 / Docker-multistage-example.MD
Last active November 3, 2023 14:52
Docker Multistage + Spring Boot = Smaller Container Sized

docker-multi-stage

Spring Boot + Docker Multistage = Smaller container size

Use can use prebuild version by using:

$ docker run -d -p 8080:8080 saboteurkid/smaller-spring:1.0

Wait for docker to pull and up. Then jump to step #6

1. Clone example project from Spring Boot repository

@liemle3893
liemle3893 / avoid-distributed-transactions.md
Created December 3, 2022 09:28 — forked from rponte/avoid-distributed-transactions.md
THEORY: Distributed Transactions and why you should avoid them (2 Phase Commit , Saga Pattern, TCC, Idempotency etc)

Distributed Transactions and why you should avoid them

  1. Modern technologies won't support it (RabbitMQ, Kafka, etc.);
  2. This is a form of using Inter-Process Communication in a synchronized way and this reduces availability;
  3. All participants of the distributed transaction need to be avaiable for a distributed commit, again: reduces availability.

Implementing business transactions that span multiple services is not straightforward. Distributed transactions are best avoided because of the CAP theorem. Moreover, many modern (NoSQL) databases don’t support them. The best solution is to use the Saga Pattern.

[...]

job "demo" {
datacenters = [
"dc1"]
group "api" {
count = "1"
task "demo_api" {
driver = "docker"
config {
image = "saboteurkid/go-demo:latest-debug"
port_map {
job "minio" {
datacenters = ["dc1"]
type = "service"
group "minio1" {
ephemeral_disk {
size = 10000
sticky = true
migrate = false
}
@liemle3893
liemle3893 / jenkins.your-domain.com
Created May 11, 2018 18:49
Jenkins subdomain - NginX config. ( /etc/nginx/sites-available/jenkins.your-domain.com )
server {
listen 80;
server_name jenkins.your-domain.com;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
@liemle3893
liemle3893 / private_fork.md
Created September 5, 2021 08:06 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

@liemle3893
liemle3893 / COMMANDS.MD
Last active July 21, 2021 11:34
Ory hydra common client's commands

Hydra

Version: v1.10.2

Create

hydra clients create   \
 --endpoint http://127.0.0.1:4445     \
 --id 111111    \
 --secret 123456    \

HOWTO: Clean Up Nomad Data Directory

Issue

When attempting to remove all of the data in the Nomad data directory, several directories and files are unable to be deleted. Many messages are logged to the console like:

rm: cannot remove ‘alloc/736f61b9-d7dc-cb73-0dd1-76b1b2ba032d/nomad-ui/secrets’: Device or resource busy
rm: cannot remove ‘alloc/ddcf5a78-5497-f4a4-a101-221fc4e0180b/fabio/alloc’: Device or resource busy
rm: cannot remove ‘alloc/ddcf5a78-5497-f4a4-a101-221fc4e0180b/fabio/secrets’: Device or resource busy
[SERVICE]
Flush 1
Log_Level info
Parsers_File parsers.conf
[INPUT]
Name tail
# Log file will be placed at: /tmp/fluent-bit/logs/<app_name>/<file_name>.log
Path /tmp/fluent-bit/logs/*/*.log
Path_Key LogSource