Container之間有關係時可以用docker command中的–link搞定
當有多個Container需要連結時我們會希望能撰寫一份設定檔定義Container之間的關係然後執行就好
這就是docker-compose在做的事
撰寫docker-compose.yml定義各Container link relation
然後run docker-compose up -d

Command

1
docker-compose -f ./docker-compose.yml up -d

docker-compose.yml example

以下設定表示
faceblock是ap server
zombodb_postgres是postgres database
zombodb_elastic是elasticsearch database
faceblock相依於zombodb_postgres
zombodb_postgres相依於zombodb_elastic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
faceblock:
build: ./faceblock # DockerFile location
ports: # export ports
- "3001:3000"
- "3043:443"
links: # dependency
- zombodb_postgres
entrypoint: /execute.sh
zombodb_postgres:
build: ./postgres
ports:
- "5432:5432"
links:
- zombodb_elastic
restart: always # auto restart while exit
zombodb_elastic:
build: ./elasticsearch
ports:
- "9200:9200"
- "9300:9300"
restart: always

Comment and share

Create-React-App正常使用下無法更改babel設定
且為了保持產生的bundle.js不會太大
Create-React-App並不會將babel-polyfill全部打開
例如以下這些在IE中將會失敗的Function
Array.includes, String.includes, Object.values
以下簡單介紹3種解決辦法

Continue reading

Domain Setting

  1. 買一個domain(namecheap之類的)
  2. 照著官方文件做吧
    https://www.digitalocean.com/community/tutorials/how-to-set-up-a-host-name-with-digitalocean

Swap Setting

Digital Ocean每月5美金的那個VPS,記憶體只有512MB
並且Digital Ocean預設OS的Swap是關閉的(官方說明SSD不建議使用swap)
若在上面再用docker的話高機率因為記憶體不足process被kill掉
若是真的不想加錢買更多記憶體的話還是可以手動開啟swap

一樣官方文件照著做就好
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

Comment and share

A Simple Higher Order Component example

Simple example

For loading spinner with different Component

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// HOC declaration
function withLoadingSpinner(Component) {
return function EnhancedComponent({ isLoading, ...props }) {
if (!isLoading) {
return <Component { ...props } />;
}
return <LoadingSpinner />;
};
}
// Usage
const ListItemsWithLoadingIndicator = withLoadingSpinner(ListItems);
<ListItemsWithLoadingIndicator
isLoading={props.isLoading}
list={props.list}
/>

Recompose

https://github.com/rafrex/spa-github-pages
A React Library for HOC

Comment and share

Cwza

Hello everyone.
I’m cwza.
Welcome to my blog.


Software Engineer


Taiwan/Taipei