Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed security-bootstrapper Docker volume init semantics #4085

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions cmd/security-bootstrapper/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ RUN make cmd/security-bootstrapper/security-bootstrapper
FROM alpine:3.14

LABEL license='SPDX-License-Identifier: Apache-2.0' \
copyright='Copyright (c) 2021 Intel Corporation'
copyright='Copyright (c) 2022 Intel Corporation'

RUN apk add --update --no-cache dumb-init su-exec

ENV SECURITY_INIT_DIR /edgex-init
ARG BOOTSTRAP_REDIS_DIR=${SECURITY_INIT_DIR}/bootstrap-redis
ENV SECURITY_INIT_STAGING /edgex-init-staging
ARG BOOTSTRAP_REDIS_DIR=${SECURITY_INIT_STAGING}/bootstrap-redis

RUN mkdir -p ${SECURITY_INIT_DIR} \
&& mkdir -p ${BOOTSTRAP_REDIS_DIR}
RUN mkdir -p ${BOOTSTRAP_REDIS_DIR}

WORKDIR ${SECURITY_INIT_DIR}
WORKDIR ${SECURITY_INIT_STAGING}

# copy all entrypoint scripts into shared folder
COPY --from=builder /edgex-go/cmd/security-bootstrapper/entrypoint-scripts/ ${SECURITY_INIT_DIR}/
RUN chmod +x ${SECURITY_INIT_DIR}/*.sh
COPY --from=builder /edgex-go/cmd/security-bootstrapper/entrypoint-scripts/ ${SECURITY_INIT_STAGING}/
RUN chmod +x ${SECURITY_INIT_STAGING}/*.sh

COPY --from=builder /edgex-go/Attribution.txt /
COPY --from=builder /edgex-go/cmd/security-bootstrapper/security-bootstrapper .
Expand All @@ -59,10 +59,7 @@ COPY --from=builder /edgex-go/cmd/security-bootstrapper/res/configuration.toml .
COPY --from=builder /edgex-go/cmd/security-bootstrapper/res-bootstrap-redis/configuration.toml ${BOOTSTRAP_REDIS_DIR}/res/

# copy Consul ACL related configs
COPY --from=builder /edgex-go/cmd/security-bootstrapper/consul-acl/ ${SECURITY_INIT_DIR}/consul-bootstrapper/

# Expose the file directory as a volume since there's long-running state
VOLUME ${SECURITY_INIT_DIR}
COPY --from=builder /edgex-go/cmd/security-bootstrapper/consul-acl/ ${SECURITY_INIT_STAGING}/consul-bootstrapper/

# setup entry point script
COPY --from=builder /edgex-go/cmd/security-bootstrapper/entrypoint.sh /
Expand Down
7 changes: 5 additions & 2 deletions cmd/security-bootstrapper/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# zombie processes
#
# ----------------------------------------------------------------------------------
# Copyright (c) 2021 Intel Corporation
# Copyright (c) 2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,9 @@ fi
DEFAULT_EDGEX_USER_ID=2002
EDGEX_USER_ID=${EDGEX_USER:-$DEFAULT_EDGEX_USER_ID}

# assumming the target directory ${SECURITY_INIT_DIR} has been created by the framework
cp -rpd ${SECURITY_INIT_STAGING}/* ${SECURITY_INIT_DIR}/

# During the bootstrapping, environment variables come for compose file environment files,
# which then injecting into all other related containers on other services' entrypoint scripts
# if the executable is not 'security-bootstrapper'; then we consider it not running the bootstrapping process
Expand All @@ -46,4 +49,4 @@ else
# for debug purposes like docker run -it --rm security-bootstrapper:0.0.0-dev /bin/sh
echo "current directory:" "$PWD"
exec su-exec ${EDGEX_USER_ID} "$@"
fi
fi