Bläddra i källkod

:wrench: add startup scripts

China Kassapa 3 månader sedan
förälder
incheckning
cc23779dae
5 ändrade filer med 46 tillägg och 6 borttagningar
  1. 1 0
      docker/.gitignore
  2. 2 6
      docker/mint/build.sh
  3. 28 0
      scripts/container/mint.sh
  4. 3 0
      scripts/container/run.sh
  5. 12 0
      scripts/container/test.sh

+ 1 - 0
docker/.gitignore

@@ -1,3 +1,4 @@
 *.tar
 *.tar.??
 *.md5
+.tmp-*

+ 2 - 6
docker/mint/build.sh

@@ -9,12 +9,8 @@ if [ "$#" -ne 1 ]; then
 fi
 
 export VERSION=$(date "+%4Y%m%d%H%M%S")
-export CODE="mint-php$1-$(uname -m)"
-export TAR="$CODE-$VERSION"
-
-# podman pull ubuntu:latest
-# podman build --build-arg PHP_VERSION=$1 -t $CODE .
-# podman save --format=oci-archive -o $TAR.tar $CODE
+export CODE="mint-php$1"
+export TAR="$CODE-$(uname -m)-$VERSION"
 
 docker pull ubuntu:latest
 docker build --build-arg PHP_VERSION=$1 -t $CODE .

+ 28 - 0
scripts/container/mint.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+set -e
+
+# -----------------------------------------------------------------------------
+if [[ "$EUID" -ne 0 ]]; then
+    echo "please run this script as root."
+    exit 1
+fi
+
+. /etc/os-release
+if [[ "$ID" != "ubuntu" ]]; then
+    echo "unsupported distribution $ID"
+    exit 1
+fi
+# -----------------------------------------------------------------------------
+
+if [[ "$#" -eq 1 && "$1" == "diagnose" ]]; then
+    php --version
+    echo "NodeJs: $(node -v)"
+    echo "npm: $(npm -v)"
+    composer diagnose
+else
+    echo "unsupported args, USAGE: $0 diagnose|api-v8 PORT|api-v12 PORT"
+    exit 1
+fi
+
+exit 0

+ 3 - 0
scripts/container/run.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+set -e

+ 12 - 0
scripts/container/test.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -e
+
+if [ "$#" -ne 1 ]; then
+    echo "USAGE: $0 PHP_VERSION"
+    exit 1
+fi
+
+docker run --rm -it --hostname=mint --network host -v $(dirname $PWD):/srv:z mint-php${1}
+
+exit 0