Skip to content

Commit 695e08c

Browse files
DanielHansmannAldiprofuel
authored andcommitted
Enable OSX trusted certificates to be copied into docker Container (#562)
1 parent 0baf609 commit 695e08c

15 files changed

Lines changed: 94 additions & 5 deletions

File tree

bin/command/install/bootstrap.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ function Command::bootstrap() {
7575
Console::info "Using ${projectYaml}"
7676

7777
local USER_FULL_ID=$(Environment::getFullUserId)
78+
# pipeline aus YAML mit grep/sed robust auslesen (ohne yq/PHP), nutzt $projectYaml
79+
copy_cert_from_mac=$(grep -E '^[[:space:]]*copy_cert_from_mac:' "$projectYaml" | sed -E 's/^[[:space:]]*copy_cert_from_mac:[[:space:]]*//')
80+
Console::info "Copy Cert From Mac: ${copy_cert_from_mac}"
81+
82+
if [ "${copy_cert_from_mac}" = "true" ]; then
83+
Console::info "Export System Certificates to ${SOURCE_DIR}/generator/certs-system.crt"
84+
security find-certificate -a -p /Library/Keychains/System.keychain > "${SOURCE_DIR}/generator/certs-system.crt"
85+
else
86+
Console::info "Create empty certs-system.crt at ${SOURCE_DIR}/generator/certs-system.crt"
87+
> "${SOURCE_DIR}/generator/certs-system.crt"
88+
fi
7889

7990
Console::verbose::start "Building generator..."
8091
docker build -t spryker_docker_sdk \
@@ -90,6 +101,8 @@ function Command::bootstrap() {
90101
cp -rf "${SOURCE_DIR}/context" "${tmpDeploymentDir}/context"
91102
cp -rf "${SOURCE_DIR}/bin/standalone" "${tmpDeploymentDir}/context/cli"
92103
cp -rf "${SOURCE_DIR}/images" "${tmpDeploymentDir}/images"
104+
cp -rf "${SOURCE_DIR}/generator/certs-system.crt" "${tmpDeploymentDir}/certs-system.crt"
105+
cp -rf "${SOURCE_DIR}/generator/certs-system.crt" "${tmpDeploymentDir}/context/certs-system.crt"
93106
cp "${projectYaml}" "${tmpDeploymentDir}/project.yml"
94107
cp "$([ -f "./.dockersyncignore" ] && echo './.dockersyncignore' || echo "${SOURCE_DIR}/.dockersyncignore.default")" "${tmpDeploymentDir}/.dockersyncignore"
95108
if [ -f ".known_hosts" ]; then

docs/07-deploy-file/02-deploy.file.reference.v1.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,16 @@ A **Service** to control user agents.
954954

955955
***
956956

957+
### copy_cert_from_mac:
958+
959+
A **Service** to control user agents.
960+
961+
* Project-wide
962+
* `copy_cert_from_mac: true:` - possible values are true / false. This variable is optional with the default value false. If set, the trusted CA certificate is copied from the host machine to the container. This is required to use company proxy.
963+
964+
965+
***
966+
957967
## Change log
958968

959969
* Initial reference document is introduced.

generator/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ FROM ${SPRYKER_PHP_IMAGE}
66
RUN apk add --no-cache openssl
77

88
WORKDIR /data
9+
10+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
11+
RUN update-ca-certificates
12+
913
USER spryker
1014

1115
COPY --chown=spryker:spryker composer.json composer.lock ${srcRoot}/

images/baked/application/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ ARG SPRYKER_PARENT_IMAGE
33

44
FROM ${SPRYKER_PARENT_IMAGE} AS application-production-dependencies
55

6+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
7+
RUN update-ca-certificates
8+
69
USER spryker
710

811
# Install composer modules for Spryker

images/baked/cli/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ ARG SPRYKER_PARENT_IMAGE
33

44
FROM ${SPRYKER_PARENT_IMAGE} as cli-production
55

6+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
7+
RUN update-ca-certificates
8+
69
USER spryker
710

811
# Install composer modules for Spryker

images/baked/frontend/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ ARG SPRYKER_PARENT_IMAGE
33
ARG SPRYKER_ASSETS_BUILDER_IMAGE
44

55
FROM ${SPRYKER_ASSETS_BUILDER_IMAGE} as assets-builder
6-
76
FROM ${SPRYKER_PARENT_IMAGE} as frontend-production
87

8+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
9+
RUN update-ca-certificates
10+
911
RUN mkdir -p /data/public && chmod 0777 /data/public
1012
COPY --from=assets-builder --chown=root:root /data/public /data/public

images/common/application-local/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ FROM ${SPRYKER_PARENT_IMAGE} AS application-local
44

55
# Make self-signed certificate to be trusted locally
66
COPY nginx/ssl/ca.crt /usr/local/share/ca-certificates
7+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
78
RUN update-ca-certificates

images/common/application/Dockerfile.twig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ FROM ${SPRYKER_NODE_IMAGE} AS node
88

99
ARG SPRYKER_NPM_VERSION
1010

11-
RUN npm install -g npm@${SPRYKER_NPM_VERSION}
11+
# Temporarily switch to HTTP for Alpine repositories to bootstrap ca-certificates
12+
RUN sed -i 's/https:\/\/dl-cdn.alpinelinux.org/http:\/\/dl-cdn.alpinelinux.org/g' /etc/apk/repositories \
13+
&& apk add --no-cache ca-certificates \
14+
&& sed -i 's/http:\/\/dl-cdn.alpinelinux.org/https:\/\/dl-cdn.alpinelinux.org/g' /etc/apk/repositories
15+
16+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
17+
RUN update-ca-certificates
18+
19+
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/host-certs.crt
20+
RUN npm config set cafile /usr/local/share/ca-certificates/host-certs.crt \
21+
&& npm install -g npm@${SPRYKER_NPM_VERSION}
1222

1323
FROM ${SPRYKER_PLATFORM_IMAGE} AS application-basic
1424

images/common/cli/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ ARG SPRYKER_PARENT_IMAGE
33

44
FROM ${SPRYKER_PARENT_IMAGE} as cli-basic
55

6+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
7+
RUN update-ca-certificates
8+
9+
#TEST
10+
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/host-certs.crt
11+
RUN npm config set cafile /usr/local/share/ca-certificates/host-certs.crt
12+
13+
614
# Blackfire client
715
RUN mkdir -p /tmp/blackfire \
816
&& architecture=$(case $(uname -m) in i386 | i686 | x86) echo "i386" ;; x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \

images/common/dashboard/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@ ARG SPRYKER_DASHBOARD_IMAGE=node:alpine
22

33
FROM ${SPRYKER_DASHBOARD_IMAGE} AS dashboard
44

5+
RUN sed -i 's/https:\/\/dl-cdn.alpinelinux.org/http:\/\/dl-cdn.alpinelinux.org/g' /etc/apk/repositories \
6+
&& apk add --no-cache ca-certificates \
7+
&& sed -i 's/http:\/\/dl-cdn.alpinelinux.org/https:\/\/dl-cdn.alpinelinux.org/g' /etc/apk/repositories
8+
COPY certs-system.crt "/usr/local/share/ca-certificates/host-certs.crt"
9+
RUN update-ca-certificates
10+
511
RUN mkdir -p /dashboard
612
WORKDIR /dashboard
713
ENV HOME=/dashboard
8-
14+
ENV NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/host-certs.crt
15+
RUN npm config set cafile /usr/local/share/ca-certificates/host-certs.crt
916
RUN npm install log.io pm2 -g
1017

1118
COPY context/dashboard/package.json context/dashboard/package-lock.json /dashboard/

0 commit comments

Comments
 (0)