Skip to content

Commit

Permalink
Merge pull request #509 from spryker/al-ops-stable-arg-images
Browse files Browse the repository at this point in the history
Add variables for images
  • Loading branch information
maritechpro authored Aug 30, 2024
2 parents ad6e2e7 + 2095621 commit 5e6c7fa
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 22 deletions.
1 change: 1 addition & 0 deletions bin/sdk/assets/baked.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function Assets::build() {
-f "${DEPLOYMENT_PATH}/images/baked/assets/Dockerfile" \
--progress="${PROGRESS_TYPE}" \
--build-arg "SPRYKER_PARENT_IMAGE=${cliImage}" \
--build-arg "SPRYKER_PHP_IMAGE=${SPRYKER_PHP_IMAGE:-spryker/php:8.2}" \
--build-arg "SPRYKER_ASSETS_MODE=${mode}" \
--build-arg "SPRYKER_PIPELINE=${SPRYKER_PIPELINE}" \
--build-arg "SPRYKER_BUILD_HASH=${SPRYKER_BUILD_HASH:-"current"}" \
Expand Down
4 changes: 4 additions & 0 deletions bin/sdk/images/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function Images::_buildApp() {
-f "${DEPLOYMENT_PATH}/images/common/application/Dockerfile" \
--progress="${PROGRESS_TYPE}" \
--build-arg "SPRYKER_PLATFORM_IMAGE=${SPRYKER_PLATFORM_IMAGE}" \
--build-arg "SPRYKER_PHP_IMAGE=${SPRYKER_PHP_IMAGE:-spryker/php:8.2}" \
--build-arg "SPRYKER_LOG_DIRECTORY=${SPRYKER_LOG_DIRECTORY}" \
--build-arg "SPRYKER_PIPELINE=${SPRYKER_PIPELINE}" \
--build-arg "APPLICATION_ENV=${APPLICATION_ENV}" \
Expand All @@ -63,6 +64,7 @@ function Images::_buildApp() {
--build-arg "SPRYKER_NODE_IMAGE_VERSION=${SPRYKER_NODE_IMAGE_VERSION}" \
--build-arg "SPRYKER_NODE_IMAGE_DISTRO=${SPRYKER_NODE_IMAGE_DISTRO}" \
--build-arg "SPRYKER_NPM_VERSION=${SPRYKER_NPM_VERSION}" \
--build-arg "SPRYKER_NODE_IMAGE=${SPRYKER_NODE_IMAGE}" \
"${DEPLOYMENT_PATH}/context" 1>&2

docker build \
Expand All @@ -72,6 +74,7 @@ function Images::_buildApp() {
--secret "id=secrets-env,src=$SECRETS_FILE_PATH" \
--progress="${PROGRESS_TYPE}" \
--build-arg "SPRYKER_PARENT_IMAGE=${baseAppImage}" \
--build-arg "SPRYKER_PHP_IMAGE=${SPRYKER_PHP_IMAGE:-spryker/php:8.2}" \
--build-arg "SPRYKER_DOCKER_PREFIX=${SPRYKER_DOCKER_PREFIX}" \
--build-arg "SPRYKER_DOCKER_TAG=${SPRYKER_DOCKER_TAG}" \
--build-arg "USER_UID=${USER_FULL_ID%%:*}" \
Expand Down Expand Up @@ -199,6 +202,7 @@ function Images::_buildGateway() {
-t "${gatewayImage}" \
-f "${DEPLOYMENT_PATH}/images/common/gateway/Dockerfile" \
--progress="${PROGRESS_TYPE}" \
--build-arg "SPRYKER_GATEWAY_IMAGE=${SPRYKER_GATEWAY_IMAGE:-nginx:stable-bullseye}" \
"${DEPLOYMENT_PATH}/context" 1>&2
}

Expand Down
2 changes: 1 addition & 1 deletion ci/deploy.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace: spryker
tag: 'dev'

environment: docker
image: spryker/php:7.2
image: ${SPRYKER_CI_PHP_IMAGE:-spryker/php:8.2}

regions:
EU:
Expand Down
2 changes: 1 addition & 1 deletion ci/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace: spryker_demo
tag: '1.0'

environment: docker
image: spryker/php:7.2
image: ${SPRYKER_CI_PHP_IMAGE:-spryker/php:8.2}

regions:
EU:
Expand Down
5 changes: 3 additions & 2 deletions generator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# syntax = docker/dockerfile:experimental
ARG SPRYKER_PHP_VERSION=7.3
ARG SPRYKER_PHP_VERSION=8.2
ARG SPRYKER_PHP_IMAGE=spryker/php:${SPRYKER_PHP_VERSION}

FROM spryker/php:${SPRYKER_PHP_VERSION}
FROM ${SPRYKER_PHP_IMAGE}

RUN apk add --no-cache openssl

Expand Down
5 changes: 3 additions & 2 deletions generator/deploy-file-generator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# syntax = docker/dockerfile:experimental
ARG SPRYKER_PHP_VERSION=7.3
ARG SPRYKER_PHP_VERSION=8.2
ARG SPRYKER_PHP_IMAGE=spryker/php:${SPRYKER_PHP_VERSION}

FROM spryker/php:${SPRYKER_PHP_VERSION}
FROM ${SPRYKER_PHP_IMAGE}

WORKDIR /data
USER spryker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
assets:
image: fholzer/nginx-brotli:v1.18.0
image: ${SPRYKER_CI_FRONTEND_IMAGE:-fholzer/nginx-brotli:v1.18.0}
mode: production
compression:
brotli:
Expand Down
7 changes: 6 additions & 1 deletion generator/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ public function setIsActive(bool $isActive): void

const SPRYKER_NODE_IMAGE_DISTRO_ENV_NAME = 'SPRYKER_NODE_IMAGE_DISTRO';
const SPRYKER_NODE_IMAGE_VERSION_ENV_NAME = 'SPRYKER_NODE_IMAGE_VERSION';
const SPRYKER_NODE_IMAGE_ENV_NAME = 'SPRYKER_NODE_IMAGE';
const SPRYKER_NPM_VERSION_ENV_NAME = 'SPRYKER_NPM_VERSION';

const DEFAULT_NODE_VERSION = 12;
Expand Down Expand Up @@ -1619,7 +1620,7 @@ function buildNodeJsNpmBuildConfig(array $projectData): array
$imageName = $projectData['image']['tag'];
$nodejsConfig = $projectData['image']['node'] ?? [];

return [
$nodeJsNpmBuildConfig = [
SPRYKER_NODE_IMAGE_DISTRO_ENV_NAME => getNodeDistroName($nodejsConfig, $imageName),
SPRYKER_NODE_IMAGE_VERSION_ENV_NAME => array_key_exists('version', $nodejsConfig)
? (int)$nodejsConfig['version']
Expand All @@ -1628,6 +1629,10 @@ function buildNodeJsNpmBuildConfig(array $projectData): array
? (int)$nodejsConfig['npm']
: DEFAULT_NPM_VERSION,
];

$nodeJsNpmBuildConfig[SPRYKER_NODE_IMAGE_ENV_NAME] = 'node:' . $nodeJsNpmBuildConfig[SPRYKER_NODE_IMAGE_VERSION_ENV_NAME] . '-' . $nodeJsNpmBuildConfig[SPRYKER_NODE_IMAGE_DISTRO_ENV_NAME];

return $nodeJsNpmBuildConfig;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions generator/src/templates/deploy.bash.twig
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ declare -a -r SPRYKER_APPLICATIONS=({{ _applications | join(' ') | raw }})
declare -a -r SPRYKER_ENTRYPOINTS=({{ _entryPoints | join(' ') | raw }})
readonly COMPOSE_PROJECT_NAME={{ namespace | default('spryker') }}
readonly SPRYKER_PIPELINE=${SPRYKER_PIPELINE:-{{ pipeline | default('docker') }}}
readonly SPRYKER_PLATFORM_IMAGE=${SPRYKER_PLATFORM_IMAGE:-{{ image is iterable ? image['tag'] : image | default('spryker/php:7.2') }}}
readonly SPRYKER_PLATFORM_IMAGE=${SPRYKER_PLATFORM_IMAGE:-{{ image is iterable ? image['tag'] : image | default('spryker/php:8.2') }}}
readonly SPRYKER_DOCKER_PREFIX=${COMPOSE_PROJECT_NAME}
readonly SPRYKER_DOCKER_TAG="{{ tag | default('1.0') }}"
readonly SPRYKER_FRONTEND_IMAGE="{{ assets['image'] | default('nginx:alpine') }}"
readonly SPRYKER_FRONTEND_IMAGE=${SPRYKER_FRONTEND_IMAGE:-{{ assets['image'] | default('nginx:alpine') }}}
readonly SPRYKER_COMPOSER_MODE="{{ composer.mode | default('') }}"
readonly SPRYKER_COMPOSER_AUTOLOAD="{{ composer.autoload | default('') }}"
readonly SPRYKER_LOG_DIRECTORY="{{ docker['logs']['path'] | default('/var/log/spryker') }}"
Expand Down
2 changes: 1 addition & 1 deletion generator/src/templates/docker-compose.yml.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ x-volumes:
services:

cli_ssh_relay:
image: spryker/socat:latest
image: ${SPRYKER_CLI_SSH_RELAY_IMAGE:-spryker/socat:latest}
privileged: true
command: UNIX-LISTEN:/tmp/ssh-relay/ssh-auth.sock,fork,unlink-early,user=1000,group=1000,mode=666 UNIX-CONNECT:/tmp/ssh-relay/input-ssh-auth.sock
networks:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ serviceName }}:
image: spryker/jenkins:2.305
image: ${SPRYKER_CI_JENKINS_IMAGE:-spryker/jenkins:2.305}
networks:
- private
labels:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ serviceName }}:
image: spryker/jenkins:2.324
image: ${SPRYKER_CI_JENKINS_IMAGE:-spryker/jenkins:2.324}
networks:
- private
labels:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ serviceName }}:
image: spryker/rabbitmq:3.8
image: ${SPRYKER_CI_RABBITMQ_IMAGE:-spryker/rabbitmq:3.8}
hostname: {{ serviceName }} # RabbitMQ determines the cluster by its hostname
networks:
- private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ serviceName }}:
image: spryker/rabbitmq:3.9
image: ${SPRYKER_CI_RABBITMQ_IMAGE:-spryker/rabbitmq:3.9}
hostname: {{ serviceName }} # RabbitMQ determines the cluster by its hostname
networks:
- private
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% set protocol = project['docker']['ssl']['enabled'] ? 'https://' : 'http://' %}
{% set firstGlueEndpointMap = project['_endpointMap'] | first %}
{{ serviceName }}:
image: spryker/swagger-ui:v3.24.3
image: ${SPRYKER_CI_SWAGGER_IMAGE:-spryker/swagger-ui:v3.24.3}
networks:
- private
labels:
Expand Down
5 changes: 3 additions & 2 deletions images/common/application/Dockerfile.twig
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# syntax = docker/dockerfile:experimental
ARG SPRYKER_PLATFORM_IMAGE=spryker/php:7.3
ARG SPRYKER_PLATFORM_IMAGE=spryker/php:8.2
ARG SPRYKER_NODE_IMAGE_VERSION
ARG SPRYKER_NODE_IMAGE_DISTRO
ARG SPRYKER_NODE_IMAGE=node:${SPRYKER_NODE_IMAGE_VERSION}-${SPRYKER_NODE_IMAGE_DISTRO}

FROM node:${SPRYKER_NODE_IMAGE_VERSION}-${SPRYKER_NODE_IMAGE_DISTRO} AS node
FROM ${SPRYKER_NODE_IMAGE} AS node

ARG SPRYKER_NPM_VERSION

Expand Down
4 changes: 3 additions & 1 deletion images/common/dashboard/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:alpine AS dashboard
ARG SPRYKER_DASHBOARD_IMAGE=node:alpine

FROM ${SPRYKER_DASHBOARD_IMAGE} AS dashboard

RUN mkdir -p /dashboard
WORKDIR /dashboard
Expand Down
7 changes: 4 additions & 3 deletions images/common/services/jenkins/export/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# syntax = docker/dockerfile:experimental
ARG SPRYKER_PARENT_IMAGE
ARG SPRYKER_JENKINS_IMAGE=spryker/jenkins-boilerplate:2.471

FROM spryker/jenkins-boilerplate:2.471 as spryker-jenkins-boilerplate
FROM ${SPRYKER_JENKINS_IMAGE} as spryker-jenkins-boilerplate
FROM ${SPRYKER_PARENT_IMAGE} as spryker_jenkins
EXPOSE 8080
COPY context/jenkins/export/jenkins.docker.xml.twig ./config/Zed/cronjobs/jenkins.docker.xml.twig

COPY --from=spryker-jenkins-boilerplate /usr/share/jenkins/ref/plugins /usr/share/jenkins/ref/plugins
COPY --from=spryker-jenkins-boilerplate /usr/share/jenkins/jenkins.war /usr/share/jenkins/jenkins.war
COPY --from=spryker-jenkins-boilerplate /usr/share/jenkins/jenkins-cli.jar /usr/share/jenkins/jenkins-cli.jar

# Install packages on Alpine
RUN bash -c 'if [ ! -z "$(which apk)" ]; then apk --no-cache add \
curl \
Expand All @@ -35,7 +36,7 @@ RUN bash -c 'if [ ! -z "$(which apt)" ]; then apt update -y && \
jq \
&& \
mkdir -p /envs \
; fi'
; fi'

COPY terraform/cli /envs/
COPY context/jenkins/export/entrypoint.sh /entrypoint.sh
Expand Down

0 comments on commit 5e6c7fa

Please sign in to comment.