@@ -5,7 +5,7 @@ RUN curl -L0 https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linu
55WORKDIR /app
66COPY --chown=nonroot ./terraform ./terraform
77RUN mkdir -p infrastructure-templates
8- # COPY --chown=nonroot ./infrastructure-templates ./infrastructure-templates
8+ COPY --chown=nonroot ./infrastructure-templates ./infrastructure-templates
99ENV TF_PLUGIN_CACHE_DIR="/app/.terraform.d/plugin-cache"
1010# COPY .terraform.d.zip /app/terraform.zip
1111RUN mkdir -p $TF_PLUGIN_CACHE_DIR
@@ -20,39 +20,39 @@ RUN <<'EOF'
2020 wait
2121
2222 tdir=$(basename $(dirname $TF_PLUGIN_CACHE_DIR))
23- # tar cf - $tdir | lz4 -v -5 > tf.lz4 && rm -rf $tdir
2423 tar cf - $tdir | zstd --compress > tf.zst && rm -rf $tdir
2524EOF
2625
2726# ENV DECOMPRESS_CMD="lz4 -d tf.lz4 | tar xf -"
2827ENV DECOMPRESS_CMD="zstd --decompress tf.zst --stdout | tar xf -"
2928ENV TEMPLATES_DIR="/app/infrastructure-templates"
30-
31- # WORKDIR /app
32- # ENV TF_PLUGIN_CACHE_DIR="/app/.terraform.d/plugin-cache"
33- # RUN mkdir -p $TF_PLUGIN_CACHE_DIR
34- # RUN cat > script.sh <<EOF
35- # #!/usr/bin/env bash
36- # echo "hi" >> log.file
37- # ls -d ./infrastructure-templates/{gcp,aws}/* | tee log.file | xargs -I{} bash -c "echo name is {}; $(terraform init chdir={} -backend=false &)"
38- # # for dir in $(ls -d ./infrastructure-templates/{gcp,aws}/*); do
39- # # echo $dir >> log.file
40- # # pushd $dir
41- # # terraform init -backend=false &
42- # # popd
43- # # done
44- #
45- # wait
4629#
47- # tdir=$(basename $(dirname $TF_PLUGIN_CACHE_DIR))
48- # tar cf - $tdir | lz4 -v -5 > tf.lz4 && rm -rf $tdir
49- # EOF
50- #
51- # COPY --chown=nonroot ./terraform ./terraform
52- # COPY --chown=nonroot ./infrastructure-templates ./infrastructure-templates
53- # RUN --mount=type=cache,id=sample,target=/app/.terraform.d/plugin-cache \
54- # chmod +x /app/script.sh && bash /app/script.sh
55- # RUN adduser --disabled-password --home="/app" --uid 1717 nonroot
56- # USER nonroot
30+ WORKDIR /app
31+ ENV TF_PLUGIN_CACHE_DIR="/app/.terraform.d/plugin-cache"
32+ RUN mkdir -p $TF_PLUGIN_CACHE_DIR
33+ RUN cat > script.sh <<EOF
34+ COPY --chown=nonroot ./terraform ./terraform
35+ COPY --chown=nonroot ./infrastructure-templates ./infrastructure-templates
36+ RUN --mount=type=cache,id=sample,target=$TF_PLUGIN_CACHE_DIR <<EOF
37+ # !/usr/bin/env bash
38+ echo "hi" >> log.file
39+ # ls -d ./infrastructure-templates/{gcp,aws}/* | tee log.file | xargs -I{} bash -c "echo name is {}; $(terraform init chdir={} -backend=false &)"
40+ for dir in $(ls -d ./infrastructure-templates/{gcp,aws}/*); do
41+ echo $dir >> log.file
42+ pushd $dir
43+ terraform init -backend=false &
44+ popd
45+ done
46+
47+ wait
48+
49+ tdir=$(basename $(dirname $TF_PLUGIN_CACHE_DIR))
50+ echo "hello" >> log.file
51+ # tar cf - $tdir | lz4 -v -5 > tf.lz4 && rm -rf $tdir
52+ tar cf - $tdir | zstd --compress > tf.zst && rm -rf $tdir
53+ EOF
54+ RUN adduser --disabled-password --home="/app" --uid 1717 nonroot
55+ USER nonroot
5756# ENV DECOMPRESS_CMD="lz4 -d tf.lz4 | tar xf -"
58- # ENV TEMPLATES_DIR="/app/infrastructure-templates"
57+ ENV DECOMPRESS_CMD="zstd --decompress tf.zst --stdout | tar xf -"
58+ ENV TEMPLATES_DIR="/app/infrastructure-templates"
0 commit comments