浏览代码

adding swap space to fly deployment

Rodja Trappe 1 年之前
父节点
当前提交
991e7ec898
共有 2 个文件被更改,包括 17 次插入1 次删除
  1. 12 0
      fly-entrypoint.sh
  2. 5 1
      fly.dockerfile

+ 12 - 0
fly-entrypoint.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+set -e
+
+if [[ ! -z "$SWAP" ]]; then 
+  fallocate -l $(($(stat -f -c "(%a*%s/10)*7" .))) _swapfile
+  mkswap _swapfile 
+  swapon _swapfile
+fi
+
+free -hm
+df -h
+exec "$@"

+ 5 - 1
fly.dockerfile

@@ -29,4 +29,8 @@ RUN pip install .
 EXPOSE 8080
 EXPOSE 9062
 
-CMD python3 main.py
+COPY fly-entrypoint.sh /entrypoint.sh
+
+ENTRYPOINT ["/entrypoint.sh"]
+
+CMD ["python", "main.py"]