Skip to content

Commit 4510907

Browse files
committed
Enable dind
1 parent 42a6459 commit 4510907

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

README.rst

+9
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ If you want to use a locally present openapi schema, you can skip fetching the o
6666
by setting the ``USE_LOCAL_API_JSON`` environment variable. Doing so you have to manually provide the
6767
``api.json`` file containing the openapi schema in the current working directory.
6868

69+
Generate Bindings Using Docker in Docker (dind)
70+
-----------------------------------------------
71+
72+
Bindings are generated using the openapi-generator-cli docker container. If your environment itself runs in
73+
a docker container, the openapi-generator-cli container has to be started as a sibling container. For
74+
sibling containers, volumes cannot be mounted as usual. They have to be passed through from the parent
75+
container. For this to work you have to set the ``PARENT_CONRAINER_ID`` environment variable to specify the
76+
parent container in a dind environment.
77+
6978
Generating Bindings on a Filesystem Shared With Another Container
7079
-----------------------------------------------------------------
7180

generate.sh

+23-12
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,31 @@ else
6969
export VERSION=$(http ${PULP_URL}status/ | jq --arg plugin $COMPONENT_NAME -r '.versions[] | select(.component == $plugin) | .version')
7070
fi
7171

72+
# Mount volumes from parent container with `--volumes-from` option if the
73+
# `PARENT_CONTAINER_ID` is set.
74+
if [ -z $PARENT_CONTAINER_ID ]
75+
then
76+
VOLUME_OPTION="--volume ${PWD}:${volume_name}"
77+
VOLUME_DIR="/local"
78+
else
79+
VOLUME_OPTION="--volumes-from ${PARENT_CONTAINER_ID}:rw"
80+
VOLUME_DIR="${PWD}"
81+
fi
82+
7283
echo ::group::BINDINGS
7384
if [ $2 = 'python' ]
7485
then
7586
$container_exec run \
7687
$ULIMIT_COMMAND \
7788
$USER_COMMAND \
7889
--rm \
79-
-v ${PWD}:$volume_name \
90+
${VOLUME_OPTION} \
8091
docker.io/openapitools/openapi-generator-cli:v4.3.1 generate \
81-
-i /local/api.json \
92+
-i ${VOLUME_DIR}/api.json \
8293
-g python \
83-
-o /local/$1-client \
94+
-o ${VOLUME_DIR}/$1-client \
8495
--additional-properties=packageName=pulpcore.client.$1,projectName=$1-client,packageVersion=${VERSION},domainEnabled=${DOMAIN_ENABLED} \
85-
-t /local/templates/python \
96+
-t ${VOLUME_DIR}/templates/python \
8697
--skip-validate-spec \
8798
--strict-spec=false
8899
cp python/__init__.py $1-client/pulpcore/
@@ -98,14 +109,14 @@ then
98109
$container_exec run \
99110
$ULIMIT_COMMAND \
100111
$USER_COMMAND \
101-
--rm -v ${PWD}:$volume_name \
112+
--rm ${VOLUME_OPTION} \
102113
docker.io/openapitools/openapi-generator-cli:v4.3.1 generate \
103-
-i /local/api.json \
114+
-i ${VOLUME_DIR}/api.json \
104115
-g ruby \
105-
-o /local/$1-client \
116+
-o ${VOLUME_DIR}/$1-client \
106117
--additional-properties=gemName=$1_client,gemLicense="GPLv2+",gemVersion=${VERSION},gemHomepage=https://github.com/pulp/$1 \
107118
--library=faraday \
108-
-t /local/templates/ruby \
119+
-t ${VOLUME_DIR}/templates/ruby \
109120
--skip-validate-spec \
110121
--strict-spec=false
111122
fi
@@ -114,12 +125,12 @@ then
114125
$container_exec run \
115126
$ULIMIT_COMMAND \
116127
$USER_COMMAND \
117-
--rm -v ${PWD}:$volume_name \
128+
--rm ${VOLUME_OPTION} \
118129
docker.io/openapitools/openapi-generator-cli:v5.2.1 generate \
119-
-i /local/api.json \
130+
-i ${VOLUME_DIR}/api.json \
120131
-g typescript-axios \
121-
-o /local/$1-client \
122-
-t /local/templates/typescript-axios \
132+
-o ${VOLUME_DIR}/$1-client \
133+
-t ${VOLUME_DIR}/templates/typescript-axios \
123134
--skip-validate-spec \
124135
--strict-spec=false
125136
fi

0 commit comments

Comments
 (0)