diff --git a/local-docker-env/Dockerfile.boot b/local-docker-env/Dockerfile.boot index 12e0a7c9d6d7..17e95a8abacc 100644 --- a/local-docker-env/Dockerfile.boot +++ b/local-docker-env/Dockerfile.boot @@ -1,3 +1,6 @@ +# Specifies the version of Ubuntu to be used in the Docker image. +ARG UBUNTU_VERSION + # Stage 1: Build stage FROM golang:1.19 as builder @@ -39,7 +42,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:latest +FROM ubuntu:${UBUNTU_VERSION} # Update and upgrade the package list RUN apt-get update && \ @@ -85,7 +88,7 @@ RUN rm -rf nodekey # Run init-boot.sh RUN chmod a+x bin/init-boot.sh -CMD ./bin/init-boot.sh && tail -f /dev/null +CMD ./bin/init-boot.sh && tail -f logs/log # Clean up unnecessary packages RUN apt-get remove -y \ diff --git a/local-docker-env/Dockerfile.boot.git b/local-docker-env/Dockerfile.boot.git index 16b191b4fd31..1f52860298e1 100644 --- a/local-docker-env/Dockerfile.boot.git +++ b/local-docker-env/Dockerfile.boot.git @@ -1,3 +1,6 @@ +# Specifies the version of Ubuntu to be used in the Docker image. +ARG UBUNTU_VERSION + # Stage 1: Build stage FROM golang:1.19 as builder @@ -49,7 +52,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:latest +FROM ubuntu:${UBUNTU_VERSION} # Set environment variables ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt @@ -106,7 +109,7 @@ RUN rm -rf nodekey # Run init-boot.sh RUN chmod a+x bin/init-boot.sh -CMD ./bin/init-boot.sh && tail -f /dev/null +CMD ./bin/init-boot.sh && tail -f logs/log # Clean up unnecessary packages RUN apt-get remove -y \ diff --git a/local-docker-env/Dockerfile.node b/local-docker-env/Dockerfile.node index ae0c79545ad8..85da7dbe0274 100644 --- a/local-docker-env/Dockerfile.node +++ b/local-docker-env/Dockerfile.node @@ -1,3 +1,6 @@ +# Specifies the version of Ubuntu to be used in the Docker image. +ARG UBUNTU_VERSION + # Stage 1: Build stage FROM golang:1.19 as builder @@ -39,7 +42,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:latest +FROM ubuntu:${UBUNTU_VERSION} # Update and upgrade the package list RUN apt-get update && \ diff --git a/local-docker-env/Dockerfile.node.git b/local-docker-env/Dockerfile.node.git index 9b9894f6232c..b741be8c4236 100644 --- a/local-docker-env/Dockerfile.node.git +++ b/local-docker-env/Dockerfile.node.git @@ -1,3 +1,6 @@ +# Specifies the version of Ubuntu to be used in the Docker image. +ARG UBUNTU_VERSION + # Stage 1: Build stage FROM golang:1.19 as builder @@ -49,7 +52,7 @@ RUN apt-get remove -y \ apt-get clean # Stage 2: Runtime stage -FROM ubuntu:latest +FROM ubuntu:${UBUNTU_VERSION} # Set environment variables ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt diff --git a/local-docker-env/README.md b/local-docker-env/README.md index 56ddab1ed5b2..29a15f0b3d9a 100644 --- a/local-docker-env/README.md +++ b/local-docker-env/README.md @@ -11,12 +11,12 @@ This document explains how to set up a local testing environment based on the `g ### local-docker.sh - **Purpose**: Integrated running script for local testing based on the local repository. -- **Usage**: `./local-docker-env/local-docker.sh -a ` +- **Usage**: `./local-docker-env/local-docker.sh -a -v (optional)` ### local-docker-git.sh - **Purpose**: Integrated running script for local testing based on the Git repository. -- **Usage**: `./local-docker-env/local-docker-git.sh -a -b -r ` +- **Usage**: `./local-docker-env/local-docker-git.sh -a -b -r -v (optional)` ### key-gen.sh @@ -31,12 +31,12 @@ This document explains how to set up a local testing environment based on the `g ### docker-compose-gen.sh - **Purpose**: Generates the `docker-compose.yml` file based on the local repository. -- **Usage**: `./docker-compose-gen.sh -a -f ` +- **Usage**: `./docker-compose-gen.sh -a -f -v (optional)` ### docker-compose-gen-git.sh - **Purpose**: Generates the `docker-compose.yml` file based on the Git repository. -- **Usage**: `./docker-compose-gen-git.sh -a -f -r -b ` +- **Usage**: `./docker-compose-gen-git.sh -a -f -r -b -v (optional)` ### init-boot.sh @@ -66,11 +66,11 @@ This document explains how to set up a local testing environment based on the `g ### Execution based on the local repository code ```bash -./local-docker-env/local-docker.sh -a +./local-docker-env/local-docker.sh -a -v (optional) ``` ### Execution based on the Git repository code ```bash -./local-docker-env/local-docker-git.sh -a -b -r +./local-docker-env/local-docker-git.sh -a -b -r -v (optional) ``` diff --git a/local-docker-env/docker-compose-gen-git.sh b/local-docker-env/docker-compose-gen-git.sh index e14876dbf73d..bf0580145b39 100755 --- a/local-docker-env/docker-compose-gen-git.sh +++ b/local-docker-env/docker-compose-gen-git.sh @@ -10,7 +10,7 @@ # -f 옵션을 지정하면, 해당 경로에 docker-compose.yml 파일을 생성 # Parse command line arguments -while getopts "a:f:r:b:" opt; do +while getopts "a:f:r:b:v:" opt; do case $opt in a) account_num=$OPTARG @@ -24,6 +24,9 @@ while getopts "a:f:r:b:" opt; do b) branch_name=$OPTARG ;; + v) + version=$OPTARG + ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 @@ -58,6 +61,11 @@ if [ -z "$output_file" ]; then output_file="docker-compose.yml" fi +# Set default version if not provided +if [ -z "$version" ]; then + version="latest" +fi + # Generate docker-compose.yml content cat < "$output_file" services: @@ -74,6 +82,7 @@ for ((i=1; i<=account_num; i++)); do REPO: $repo_url BRANCH: $branch_name NODE_NUM: $i + UBUNTU_VERSION: $version image: wemix/node-boot:latest hostname: wemix-boot networks: @@ -97,6 +106,7 @@ EOF REPO: $repo_url BRANCH: $branch_name NODE_NUM: $i + UBUNTU_VERSION: $version image: wemix/node$((i-1)):latest hostname: wemix-node$((i-1)) networks: diff --git a/local-docker-env/docker-compose-gen.sh b/local-docker-env/docker-compose-gen.sh index 8c888ec9e15c..8639703a0b76 100755 --- a/local-docker-env/docker-compose-gen.sh +++ b/local-docker-env/docker-compose-gen.sh @@ -3,12 +3,14 @@ # Usage: ./gen-docker-compose.sh -a -f # -a: 계정 수 # -f: 출력 파일 -# -a 옵션은 필수이며, -f 옵션은 선택적 +# -a 옵션은 필수이며, -f, -v 옵션은 선택적 # -f 옵션을 지정하지 않으면, 현재 디렉토리에 docker-compose.yml 파일을 생성 # -f 옵션을 지정하면, 해당 경로에 docker-compose.yml 파일을 생성 +# -v 옵션을 지정하지 않으면, latest 버전으로 설정 +# -v 옵션을 지정하면, 해당 버전으로 설정 # Parse command line arguments -while getopts "a:f" opt; do +while getopts "a:f:v:" opt; do case $opt in a) account_num=$OPTARG @@ -16,6 +18,9 @@ while getopts "a:f" opt; do f) output_file=$OPTARG ;; + v) + version=$OPTARG + ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 @@ -38,6 +43,11 @@ if [ -z "$output_file" ]; then output_file="docker-compose.yml" fi +# Set default version if not provided +if [ -z "$version" ]; then + version="latest" +fi + # Generate docker-compose.yml content cat < "$output_file" services: @@ -52,6 +62,7 @@ for ((i=1; i<=account_num; i++)); do dockerfile: Dockerfile.boot args: NODE_NUM: $i + UBUNTU_VERSION: $version image: wemix/node-boot:latest hostname: wemix-boot networks: @@ -73,6 +84,7 @@ EOF dockerfile: Dockerfile.node args: NODE_NUM: $i + UBUNTU_VERSION: $version image: wemix/node$((i-1)):latest hostname: wemix-node$((i-1)) networks: diff --git a/local-docker-env/local-docker-git.sh b/local-docker-env/local-docker-git.sh index df8f66a3a403..6cf4e3c10e47 100755 --- a/local-docker-env/local-docker-git.sh +++ b/local-docker-env/local-docker-git.sh @@ -4,14 +4,8 @@ current_dir=$(pwd) export PATH=$PATH:${current_dir}/go-wemix/build/bin -# 필수 인수 확인 -if [ "$#" -ne 6 ]; then - echo "Usage: $0 -a -b -r " - exit 1 -fi - # 옵션 파싱 -while getopts "a:b:r:" opt; do +while getopts "a:b:r:v:" opt; do case ${opt} in a) ACCOUNT_NUM=$OPTARG @@ -22,6 +16,9 @@ while getopts "a:b:r:" opt; do r) REPO=$OPTARG ;; + v) + VERSION=$OPTARG + ;; \?) echo "Usage: $0 -a -b -r " exit 1 @@ -31,10 +28,15 @@ done # 필수 인수 확인 if [ -z "$ACCOUNT_NUM" ] || [ -z "$BRANCH" ] || [ -z "$REPO" ]; then - echo "Missing required arguments." + echo "Missing required arguments. Usage: $0 -a -b -r " exit 1 fi +# Set default version if not provided +if [ -z "$VERSION" ]; then + VERSION="latest" +fi + # key-gen.sh 실행 chmod +x local-docker-env/key-gen.sh ./local-docker-env/key-gen.sh -a "$ACCOUNT_NUM" || { echo "Failed to execute key-gen.sh."; exit 1; } @@ -45,7 +47,7 @@ chmod +x local-docker-env/config-gen.sh # BRANCH와 REPO 정보를 입력으로 받아 docker-compose-gen.sh 실행 chmod +x local-docker-env/docker-compose-gen-git.sh -./local-docker-env/docker-compose-gen-git.sh -a "$ACCOUNT_NUM" -b "$BRANCH" -r "$REPO" || { echo "Failed to execute docker-compose-gen-git.sh."; exit 1; } +./local-docker-env/docker-compose-gen-git.sh -a "$ACCOUNT_NUM" -b "$BRANCH" -r "$REPO" -v "$VERSION" || { echo "Failed to execute docker-compose-gen-git.sh."; exit 1; } # Dockerfile.boot.git 및 Dockerfile.node.git 파일 복사 cp local-docker-env/Dockerfile.boot.git ./ || { echo "Failed to copy Dockerfile.boot.git."; exit 1; } diff --git a/local-docker-env/local-docker.sh b/local-docker-env/local-docker.sh index 7cb3a206381d..cc57ae26d2e0 100755 --- a/local-docker-env/local-docker.sh +++ b/local-docker-env/local-docker.sh @@ -4,18 +4,15 @@ current_dir=$(pwd) export PATH=$PATH:${current_dir}/go-wemix/build/bin -# 필수 인수 확인 -if [ "$#" -ne 2 ]; then - echo "Usage: $0 -a " - exit 1 -fi - # 옵션 파싱 -while getopts "a:" opt; do +while getopts "a:v:" opt; do case ${opt} in a) ACCOUNT_NUM=$OPTARG ;; + v) + VERSION=$OPTARG + ;; \?) echo "Usage: $0 -a " exit 1 @@ -25,10 +22,15 @@ done # 필수 인수 확인 if [ -z "$ACCOUNT_NUM" ]; then - echo "Account number is required." + echo "Account number is required. Usage: $0 -a " exit 1 fi +# Set default version if not provided +if [ -z "$VERSION" ]; then + VERSION="latest" +fi + # key-gen.sh 실행 chmod +x local-docker-env/key-gen.sh ./local-docker-env/key-gen.sh -a "$ACCOUNT_NUM" || { echo "Failed to execute key-gen.sh."; exit 1; } @@ -39,7 +41,7 @@ chmod +x local-docker-env/config-gen.sh # docker-compose-gen.sh 실행 chmod +x local-docker-env/docker-compose-gen.sh -./local-docker-env/docker-compose-gen.sh -a "$ACCOUNT_NUM" || { echo "Failed to execute docker-compose-gen.sh."; exit 1; } +./local-docker-env/docker-compose-gen.sh -a "$ACCOUNT_NUM" -v "$VERSION" || { echo "Failed to execute docker-compose-gen.sh."; exit 1; } # Dockerfile.boot 및 Dockerfile.node 파일 복사 cp local-docker-env/Dockerfile.boot ./ || { echo "Failed to copy Dockerfile.boot."; exit 1; }