Skip to content

Instantly share code, notes, and snippets.

View peterwillcn's full-sized avatar
📡
011010001000100010101010101

open source peterwillcn

📡
011010001000100010101010101
View GitHub Profile
@peterwillcn
peterwillcn / install_elixir.md
Created July 26, 2018 13:17 — forked from rubencaro/install_elixir.md
Elixir installation guide

Elixir installation guide

Version numbers should be the ones you want. Here I do it with the last ones available at the moment of writing.

The simplest way to install elixir is using your package manager. Sadly, at the time of writing only Fedora shows the intention to keep its packages up to date. There you can simply sudo dnf install erlang elixir and you are good to go.

Anyway, if you intend to work with several versions of erlang or elixir at the same time, or you are tied to a specific version, you will need to compile it yourself. Then asdf is your best friend.

# Use the high-colour menu system. This file, and the low-colour 'menu.c32'
# version, are provided by the syslinux package and can be found in the
# '/var/lib/tftpboot' directory. Copy it to '/var/lib/tftpboot'.
UI vesamenu.c32
# Time out and use the default menu option. Defined as tenths of a second.
TIMEOUT 2600
# Prompt the user. Set to '1' to automatically choose the default option. This
# is really meant for files matched to MAC addresses.
@peterwillcn
peterwillcn / install_start_stop_daemon.sh
Created April 9, 2018 10:05 — forked from yuuichi-fujioka/install_start_stop_daemon.sh
install start-stop-daemon to centos, fedora, redhat.
#!/bin/bash
cd /usr/local/src
wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
tar zxvf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
cd apps/sys-utils/start-stop-daemon-IR1_9_18-2
gcc start-stop-daemon.c -o start-stop-daemon
cp start-stop-daemon /usr/sbin/
@peterwillcn
peterwillcn / Dockerfile
Created November 17, 2017 10:49 — forked from mhubig/Dockerfile
Alpine Linux based cronjob runner
FROM alpine:latest
RUN apk add --update php python py-pip mysql-client \
&& pip install awscli \
&& rm -rf /var/cache/apk/*
RUN touch crontab.tmp \
&& echo '* */6 * * * /usr/bin/php /var/www/partkeepr/app/console partkeepr:cron:run' > crontab.tmp \
&& echo '0 2 * * * /usr/bin/sql_backup' >> crontab.tmp \
&& crontab crontab.tmp \
@peterwillcn
peterwillcn / nginx.conf
Created September 29, 2017 03:43 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
package main
import (
"fmt"
"time"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
@peterwillcn
peterwillcn / pod.md
Created September 21, 2017 06:53 — forked from jianchen2580/pod.md

Pod Hand-on

Two-Container Pod

创建一个运行两个container的pod

kubectl create -f https://raw.githubusercontent.com/jianchen2580/k8s-example/master/pod/two-container-pod.yaml

查看Pod信息:

# Pod Hand-on
## Two-Container Pod
创建一个运行两个container的pod
```
kubectl create -f https://raw.githubusercontent.com/jianchen2580/k8s-example/master/pod/two-container-pod.yaml
```
查看Pod信息:
@peterwillcn
peterwillcn / pool_cx_oracle.py
Created August 10, 2017 14:06 — forked from Calzzetta/pool_cx_oracle.py
Connection pool with cx_Oracle
import cx_Oracle
def perform_query(query, bind_variables):
connection = db_pool.acquire()
cursor = connection.cursor()
cursor.execute(query, bind_variables)
result = cursor.fetchall()
cursor.close()
db_pool.release(connection)
return result

Deploying Elixir and Phoenix applications using Docker and Exrm

Goal

By the end of this quick guide, you will know how to compile a Phoenix app release using Exrm and run it inside a Docker container. I've found only a couple of articles that discuss getting an Elixir app up and running inside a Docker container, and even those only touched on some parts of the process. The idea is that this guide will give you a full end-to-end example of how to get all the pieces and parts working together so that you are able to deploy your Phoenix application inside a Docker container.

Assumptions

  1. You already have a working Elixir environment with the Phoenix Framework installed
  2. You have at least basic working knowledge of Docker, and have installed the Docker tools onto your local environment