Skip to content

Commit 654311f

Browse files
committed
chore(stacks): optimize environmental variables
1 parent c2112cb commit 654311f

21 files changed

Lines changed: 139 additions & 74 deletions

File tree

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,4 @@ RUN install-packages \
4444
zlib1g-dev \
4545
python3-pip \
4646
default-libmysqlclient-dev; \
47-
pip install oss2
48-
49-
ADD ruby.sh /etc/profile.d/ruby.sh
50-
ENV ENV /etc/profile.d/*
47+
pip install oss2

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function upload {
4848

4949
function all() {
5050
STACK_NAME=$(echo "${1}" | cut -d '@' -f 1)
51-
STACK_VERSION=$(echo "${2}" | cut -d '@' -f 2)
51+
STACK_VERSION=$(echo "${1}" | cut -d '@' -f 2)
5252

5353
build "${STACK_NAME}" "${STACK_VERSION}"
5454
upload "${STACK_NAME}"

scripts/stack-utils

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export OS_NAME="${OS_NAME:-linux}"
1111
export OS_ARCH=$(dpkg --print-architecture)
1212
export OS_FLAVOUR="${OS_FLAVOUR:-${ID}-${VERSION_ID}}"
1313
export TARNAME="${STACK_NAME}-${STACK_VERSION}-${OS_NAME}-${OS_ARCH}-${OS_FLAVOUR}"
14+
export DATA_DIR=/workspace/"${TARNAME}"/data
15+
export META_DIR=/workspace/"${TARNAME}"/meta
16+
export PROFILE_DIR=/workspace/"${TARNAME}"/data/profile.d
1417

1518
_is_sourced() {
1619
# https://unix.stackexchange.com/a/215279
@@ -20,20 +23,32 @@ _is_sourced() {
2023
}
2124

2225
function generate-stack-template() {
23-
mkdir -p /workspace/"${TARNAME}"/meta
24-
mkdir -p /workspace/"${TARNAME}"/data
26+
mkdir -p "${META_DIR}"
27+
mkdir -p "${DATA_DIR}"
28+
mkdir -p "${PROFILE_DIR}"
2529
touch /workspace/"${TARNAME}"/meta/dependencies
2630
touch /workspace/"${TARNAME}"/meta/preinstall
2731
touch /workspace/"${TARNAME}"/meta/postinstall
2832
chmod +x /workspace/"${TARNAME}"/meta/preinstall /workspace/"${TARNAME}"/meta/postinstall
2933
}
3034

3135
function generate-stack-package() {
32-
dist_dir="${1:? miss dist dir}"
36+
dist_dir="${1:? miss dist dir}"/"${STACK_NAME}"
37+
mkdir -p "${dist_dir}"
3338
tar --numeric-owner -czf "${dist_dir}"/${TARNAME}.tar.gz -C /workspace/"${TARNAME}" . --transform='s,^./,,'
3439
rm -rf /workspace/"${TARNAME}"
3540
}
3641

42+
function generate-stack-path() {
43+
cat << EOF > ${PROFILE_DIR}/${STACK_NAME}.sh
44+
export PATH="/opt/drycc/${STACK_NAME}/bin:\$PATH"
45+
EOF
46+
}
47+
48+
function source-stack-path() {
49+
. "${PROFILE_DIR}"/"${STACK_NAME}".sh
50+
}
51+
3752
function build-stack() {
3853
generate-stack-template
3954
build

stacks/erlang/build.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55

66
# Implement build function
77
function build() {
8-
cat << EOF > "${TARNAME}"/meta/dependencies
8+
generate-stack-path
9+
cat << EOF > "${META_DIR}"/dependencies
910
libssl1.1
1011
libodbc1
1112
libsctp1
1213
libwxgtk3.0
1314
EOF
14-
mkdir -p /opt/drycc/erlang/profile.d
15-
cat << EOF > /opt/drycc/erlang/profile.d/erlang.sh
16-
export PATH="/opt/drycc/erlang/bin:\$PATH"
17-
EOF
18-
. /opt/drycc/erlang/profile.d/erlang.sh
15+
source-stack-path
1916
./make.sh
20-
cp -rf /opt/drycc/erlang /workspace/"${TARNAME}"/data
17+
cp -rf /opt/drycc/erlang/* ${DATA_DIR}
2118
}
2219

2320
# call build stack

stacks/erlang/make.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ REBAR3_VERSION=$(curl -Ls https://github.com/erlang/rebar3/releases|grep /erlang
33

44
set -xe \
55
&& OTP_DOWNLOAD_URL="https://github.com/erlang/otp/archive/OTP-${OTP_VERSION}.tar.gz" \
6-
&& OTP_DOWNLOAD_SHA256="2854318d12d727fc508e8fd5fe6921c0cbc7727d1183ad8f6f808585496e42d6" \
76
&& runtimeDeps='libodbc1 libsctp1 libwxgtk3.0' \
87
&& buildDeps='unixodbc-dev libsctp-dev libwxgtk-webview3.0-gtk3-dev' \
98
&& apt-get update \
109
&& apt-get install -y --no-install-recommends $runtimeDeps \
1110
&& apt-get install -y --no-install-recommends $buildDeps \
1211
&& curl -fSL -o otp-src.tar.gz "$OTP_DOWNLOAD_URL" \
13-
&& echo "$OTP_DOWNLOAD_SHA256 otp-src.tar.gz" | sha256sum -c - \
1412
&& export ERL_TOP="/usr/src/otp_src_${OTP_VERSION%%@*}" \
1513
&& mkdir -vp $ERL_TOP \
1614
&& tar -xzf otp-src.tar.gz -C $ERL_TOP --strip-components=1 \
@@ -28,10 +26,8 @@ set -xe \
2826

2927
set -xe \
3028
&& REBAR3_DOWNLOAD_URL="https://github.com/erlang/rebar3/archive/${REBAR3_VERSION}.tar.gz" \
31-
&& REBAR3_DOWNLOAD_SHA256="cce1925d33240d81d0e4d2de2eef3616d4c17b0532ed004274f875e6607d25d2" \
3229
&& mkdir -p /usr/src/rebar3-src \
3330
&& curl -fSL -o rebar3-src.tar.gz "$REBAR3_DOWNLOAD_URL" \
34-
&& echo "$REBAR3_DOWNLOAD_SHA256 rebar3-src.tar.gz" | sha256sum -c - \
3531
&& tar -xzf rebar3-src.tar.gz -C /usr/src/rebar3-src --strip-components=1 \
3632
&& rm rebar3-src.tar.gz \
3733
&& cd /usr/src/rebar3-src \

stacks/go/build.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
# Implement build function
77
function build() {
8+
generate-stack-path
89
curl -L -o /opt/drycc/tmp.tar.gz https://go.dev/dl/go"${STACK_VERSION}".linux-"${OS_ARCH}".tar.gz
910
cd /opt/drycc && tar -xvzf tmp.tar.gz && rm -rf tmp.tar.gz && cd -
10-
mkdir -p /opt/drycc/erlang/profile.d
11-
cat << EOF > /opt/drycc/go/profile.d/go.sh
11+
cat << EOF > "${PROFILE_DIR}"/go.sh
1212
export GOPATH="/opt/drycc/go"
13-
export PATH="\$GOPATH/bin:\$PATH"
1413
EOF
15-
cp -rf /opt/drycc/go "${TARNAME}"/data
14+
cp -rf /opt/drycc/go/* ${DATA_DIR}
1615
}
1716

1817
# call build stack

stacks/gosu/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
# Implement build function
77
function build() {
8-
BIN_DIR="${TARNAME}/data/common/bin"
8+
generate-stack-path
9+
BIN_DIR="${DATA_DIR}"/bin
910
mkdir -p "${BIN_DIR}"
1011
curl -fsSL -o "${BIN_DIR}"/"${STACK_NAME}" https://github.com/tianon/gosu/releases/download/"${STACK_VERSION}"/"${STACK_NAME}"-"${OS_ARCH}"
1112
chmod +x "${BIN_DIR}"/"${STACK_NAME}"

stacks/grafana/build.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,11 @@
55

66
# Implement build function
77
function build() {
8+
generate-stack-path
89
curl -fsSL -o tmp.tar.gz https://dl.grafana.com/oss/release/grafana-${STACK_VERSION}.linux-${OS_ARCH}.tar.gz
910
tar -xvzf tmp.tar.gz
10-
mv grafana-${STACK_VERSION} ${TARNAME}/data/grafana
11-
rm tmp.tar.gz
12-
mkdir ${TARNAME}/data/grafana/profile.d
13-
cat << EOF > ${TARNAME}/data/grafana/profile.d/grafana.sh
14-
export PATH="/opt/drycc/grafana/bin:\$PATH"
15-
EOF
11+
cp -rf grafana-${STACK_VERSION}/* ${DATA_DIR}
12+
rm -rf tmp.tar.gz grafana-${STACK_VERSION}
1613
}
1714

1815
# call build stack

stacks/influxdb/build.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@
55

66
# Implement build function
77
function build() {
8-
BIN_DIR="${TARNAME}/data/influxdb/bin"
8+
generate-stack-path
9+
BIN_DIR="${DATA_DIR}"/bin
910
mkdir -p "${BIN_DIR}"
1011

1112
curl -fsSL -o tmp.tar.gz https://dl.influxdata.com/influxdb/releases/influxdb2-${STACK_VERSION}-linux-${OS_ARCH}.tar.gz
1213
tar -xvzf tmp.tar.gz
1314
mv influxdb2-${STACK_VERSION}-linux-${OS_ARCH}/influxd "${BIN_DIR}"/influxd
1415
rm -rf tmp.tar.gz influxdb2-${STACK_VERSION}-linux-${OS_ARCH}
15-
cat << EOF > ${TARNAME}/data/influxdb/profile.d/influxdb.sh
16-
export PATH="/opt/drycc/influxdb/bin:\$PATH"
17-
EOF
1816

1917
}
2018

stacks/ini-file/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
# Implement build function
77
function build() {
8-
BIN_DIR="${TARNAME}/data/common/bin"
8+
generate-stack-path
9+
BIN_DIR="${DATA_DIR}"/bin
910
mkdir -p "${BIN_DIR}"
1011
curl -fsSL -o tmp.tar.gz https://github.com/bitnami/ini-file/releases/download/v${STACK_VERSION}/"${STACK_NAME}"-linux-"${OS_ARCH}".tar.gz
1112
tar -xvzf tmp.tar.gz

0 commit comments

Comments
 (0)