Skip to content

Commit

Permalink
fix(server): move config files from buildtime to runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jun 12, 2024
1 parent 65a30d4 commit 159d11c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
volumes:
- server-certs:/certs
- ./sztp-server/images:/media
- ./sztp-server/config:/mnt
environment:
SZTPD_INIT_PORT: 6080
SZTPD_NBI_PORT: 7080
Expand All @@ -41,6 +42,7 @@ services:
condition: service_completed_successfully
volumes:
- server-certs:/certs
- ./sztp-server/config/sztpd.redirect.json.template:/mnt/sztpd.redirect.json.template
environment:
SZTPD_INIT_PORT: 6080
SZTPD_NBI_PORT: 7070
Expand Down
12 changes: 0 additions & 12 deletions sztp-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
# Copyright (c) 2022 Dell Inc, or its subsidiaries.

FROM ghcr.io/opiproject/sztpd:main@sha256:3486f2ae45bb2535d86bc03aa63cc520ad8b556960cc69b309f8320e01e59653

# configurations, images, templates
COPY config/ /tmp/

# hadolint ignore=SC2016
RUN \
cp /tmp/sztpd.redirect.json.template /tmp/redirect.json.configs && \
PRE_SCRIPT_B64=`openssl enc -base64 -A -in /tmp/my-pre-configuration-script.sh` \
POST_SCRIPT_B64=`openssl enc -base64 -A -in /tmp/my-post-configuration-script.sh` \
CONFIG_B64=`openssl enc -base64 -A -in /tmp/my-configuration.xml` \
envsubst '$PRE_SCRIPT_B64,$POST_SCRIPT_B64,$CONFIG_B64' < /tmp/sztpd.running.json.template > /tmp/running.json.configs

COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Expand Down
8 changes: 7 additions & 1 deletion sztp-server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ wait_curl () {
}

env
diff /tmp/sztpd."${SZTPD_OPI_MODE}".json.template /tmp/"${SZTPD_OPI_MODE}".json.configs || true

# shellcheck disable=SC2016
PRE_SCRIPT_B64=$(openssl enc -base64 -A -in /mnt/my-pre-configuration-script.sh) \
POST_SCRIPT_B64=$(openssl enc -base64 -A -in /mnt/my-post-configuration-script.sh) \
CONFIG_B64=$(openssl enc -base64 -A -in /mnt/my-configuration.xml) \
envsubst '$PRE_SCRIPT_B64,$POST_SCRIPT_B64,$CONFIG_B64' < /mnt/sztpd."${SZTPD_OPI_MODE}".json.template > /tmp/"${SZTPD_OPI_MODE}".json.configs
diff /mnt/sztpd."${SZTPD_OPI_MODE}".json.template /tmp/"${SZTPD_OPI_MODE}".json.configs || true

# shellcheck disable=SC2016
BOOT_IMG_HASH_VAL=$(openssl dgst -sha256 -c /media/my-boot-image.img | awk '{print $2}') \
Expand Down

0 comments on commit 159d11c

Please sign in to comment.