Skip to content

Commit

Permalink
Make Shopify images modular, add old images, bump Rust version
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Köpcke <marco.koepcke@tudock.de>
  • Loading branch information
theCapypara committed Jul 31, 2024
1 parent eb8d90c commit c048156
Show file tree
Hide file tree
Showing 39 changed files with 2,792 additions and 6 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,24 @@ jobs:
- path: sphinx
tags:
- riptidepy/sphinx:latest
- path: shopify
- path: shopify/n18.19.0/p8.1
tags:
- riptidepy/shopify:n18.19_p8.1
- path: shopify/n18.19.0/p8.2
tags:
- riptidepy/shopify:n18.19_p8.2
- path: shopify/n18.19.0/p8.3
tags:
- riptidepy/shopify:n18.19_p8.3
- path: shopify/n20.11.0/p8.1
tags:
- riptidepy/shopify:n20.11_p8.1
- path: shopify/n20.11.0/p8.2
tags:
- riptidepy/shopify:n20.11_p8.2
- path: shopify/n20.11.0/p8.3
tags:
- riptidepy/shopify:n20.11_p8.3
- path: keycloak/latest
tags:
- riptidepy/keycloak:latest
Expand Down
13 changes: 10 additions & 3 deletions shopify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@ Please update your projects to use a version following the new scheme:
{firstLowercaseCharacterOfLanguage[anOptionalSecondCharacter]}{version} divided by underscores e.g.: `n20.11_p8.1`
Ruby and Rust are skipped for now since we assume that there is no need for containers with specific versions of these languages.

The Rust version in all of these images is updated to the latest version available in the Alpine version
used at build time. See below for current versions.

| V | Node | PHP | Ruby | Rust |
|-------------|-------|-----|------|------|
| latest | 18.16 | 8.1 | | |
| n20.11_p8.1 | 20.11 | 8.1 | 3.1 | 1.60 |
| n18.19_p8.3 | 18.19 | 8.3 | 3.1 | 1.60 |
| latest | 18.16 | 8.1 | | 1.60 |
| n18.19_p8.1 | 18.19 | 8.1 | 3.1 | 1.78 |
| n18.19_p8.2 | 18.19 | 8.2 | 3.1 | 1.78 |
| n18.19_p8.3 | 18.19 | 8.3 | 3.1 | 1.78 |
| n20.11_p8.1 | 20.11 | 8.1 | 3.1 | 1.78 |
| n20.11_p8.2 | 20.11 | 8.2 | 3.1 | 1.78 |
| n20.11_p8.3 | 20.11 | 8.3 | 3.1 | 1.78 |
File renamed without changes.
12 changes: 12 additions & 0 deletions shopify/builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
shopify builder
===============

Build script to update the individual images.

Creates the Dockerfile's in the other directories.

Needs requirements:

```
pip3 install jinja2
```
File renamed without changes.
46 changes: 46 additions & 0 deletions shopify/builder/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
import os.path
import shutil

from jinja2 import Environment, FileSystemLoader

NODE_VERSIONS = {
# Checksum
"18.19.0": "10b7b23b6b867a25f060a433b83f5c3ecb3bcf7cdba1c0ce46443065a832fd41",
"20.11.0": "a8bec39586538896715be7a2ca7ef08727a58ad94d25876c5db11cafacff4c37",
}
PHP_VERSIONS = ["8.1", "8.2", "8.3"]
ALPINE_VERSION = "3.20" # Rust 1.78
COPY_FILES = [
"base.makefile",
"entrypoint.sh",
"Makefile",
"shopify-app.md"
]
BASE_DIR = os.path.join(os.path.dirname(__file__), "..")
BUILDER_DIR = os.path.join(BASE_DIR, "builder")

if __name__ == "__main__":
env = Environment(
loader=FileSystemLoader(os.path.join(BUILDER_DIR, "jinja_tpl")),
)
template = env.get_template("Dockerfile.jinja2")

for node_version, node_checksum in NODE_VERSIONS.items():
for php_version in PHP_VERSIONS:
outdir = os.path.join(BASE_DIR, f"n{node_version}", f"p{php_version}")
shutil.rmtree(outdir, ignore_errors=True)
os.makedirs(outdir)
for file in COPY_FILES:
shutil.copy(
os.path.join(BUILDER_DIR, file),
os.path.join(outdir, file),
)

with open(os.path.join(outdir, "Dockerfile"), "w") as f:
f.write(template.render(
alpine_version=ALPINE_VERSION,
node_version=node_version,
php_version=php_version,
node_checksum=node_checksum
))
File renamed without changes.
168 changes: 168 additions & 0 deletions shopify/builder/jinja_tpl/Dockerfile.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
FROM php:{{ php_version }}-cli-alpine{{ alpine_version }}

ARG XDEBUG_CLIENT_HOST=host.docker.internal
ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST

ARG DOCKER_USER=docker

# add run dependencies
RUN apk add --no-cache \
openrc \
bash \
postgresql-libs \
ruby ruby-dev ruby-ffi libzip-dev \
alpine-sdk \
gcompat \
icu \
linux-headers \
freetype libjpeg-turbo libpng libwebp

# add build dependencies
RUN apk add --no-cache -t .build-deps \
postgresql-dev \
libxml2-dev \
icu-dev \
freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \
autoconf g++ make && \
# install bundler for extension deployment
gem install bundler && \
# configure xdebug
pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug && \
echo 'xdebug.mode=off' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.client_host=${XDEBUG_CLIENT_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo 'xdebug.cli_color=1' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo 'xdebug.start_with_request=yes' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
# further php configuration and permissions
docker-php-ext-configure pdo_mysql && docker-php-ext-install pdo_mysql && \
docker-php-ext-configure simplexml && docker-php-ext-install simplexml && \
docker-php-ext-configure pgsql && docker-php-ext-install pdo_pgsql && \
docker-php-ext-configure zip && docker-php-ext-install zip && \
docker-php-ext-configure intl && docker-php-ext-install intl && \
docker-php-ext-configure gd --with-jpeg --with-webp --with-freetype && docker-php-ext-install gd && \
chgrp 1000 /usr/local/etc/php/conf.d/ -R && \
chmod g+w /usr/local/etc/php/conf.d/ -R && \
# remove build dependencies
apk del --purge .build-deps

# install composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

# use the default production configuration for PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

# Node and YARN installation steps taken from https://github.com/nodejs/docker-node/blob/ab5769dc69feb4007d9aafb03316ea0e3edb4227/18/alpine3.19/Dockerfile

ENV NODE_VERSION {{ node_version }}

RUN addgroup -g 1000 ${DOCKER_USER} \
&& adduser -u 1000 -G ${DOCKER_USER} -s /bin/sh -D ${DOCKER_USER} \
&& apk add --no-cache \
libstdc++ \
&& apk add --no-cache --virtual .build-deps \
curl \
&& ARCH= OPENSSL_ARCH='linux*' && alpineArch="$(apk --print-arch)" \
&& case "${alpineArch##*-}" in \
x86_64) ARCH='x64' CHECKSUM="{{ node_checksum }}" OPENSSL_ARCH=linux-x86_64;; \
x86) OPENSSL_ARCH=linux-elf;; \
aarch64) OPENSSL_ARCH=linux-aarch64;; \
arm*) OPENSSL_ARCH=linux-armv4;; \
ppc64le) OPENSSL_ARCH=linux-ppc64le;; \
s390x) OPENSSL_ARCH=linux-s390x;; \
*) ;; \
esac \
&& if [ -n "${CHECKSUM}" ]; then \
set -eu; \
curl -fsSLO --compressed "https://unofficial-builds.nodejs.org/download/release/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz"; \
echo "$CHECKSUM node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" | sha256sum -c - \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs; \
else \
echo "Building from source" \
# backup build
&& apk add --no-cache --virtual .build-deps-full \
binutils-gold \
g++ \
gcc \
gnupg \
libgcc \
linux-headers \
make \
python3 \
# use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150
&& export GNUPGHOME="$(mktemp -d)" \
# gpg keys listed at https://github.com/nodejs/node#release-keys
&& for key in \
4ED778F539E3634C779C87C6D7062848A1AB005C \
141F07595B7B3FFE74309A937405533BE57C7D57 \
74F12602B6F1C4E913FAA37AD3A89613643B6201 \
DD792F5973C6DE52C432CBDAC77ABFA00DDBF2B7 \
61FC681DFB92A079F1685E77973F295594EC4689 \
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
890C08DB8579162FEE0DF9DB8BEAB4DFCF555EF4 \
C82FA3AE1CBEDC6BE46B9360C43CEC45C17AB93C \
108F52B48DB57BB0CC439B2997B01419BD92F80A \
A363A499291CBBC940DD62E41F10027AF002F8B0 \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION.tar.xz" \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/SHASUMS256.txt.asc" \
&& gpg --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& grep " node-v$NODE_VERSION.tar.xz\$" SHASUMS256.txt | sha256sum -c - \
&& tar -xf "node-v$NODE_VERSION.tar.xz" \
&& cd "node-v$NODE_VERSION" \
&& ./configure \
&& make -j$(getconf _NPROCESSORS_ONLN) V= \
&& make install \
&& apk del .build-deps-full \
&& cd .. \
&& rm -Rf "node-v$NODE_VERSION" \
&& rm "node-v$NODE_VERSION.tar.xz" SHASUMS256.txt.asc SHASUMS256.txt; \
fi \
&& rm -f "node-v$NODE_VERSION-linux-$ARCH-musl.tar.xz" \
# Remove unused OpenSSL headers to save ~34MB. See this NodeJS issue: https://github.com/nodejs/node/issues/46451
&& find /usr/local/include/node/openssl/archs -mindepth 1 -maxdepth 1 ! -name "$OPENSSL_ARCH" -exec rm -rf {} \; \
&& apk del .build-deps \
# smoke tests
&& node --version \
&& npm --version

ENV YARN_VERSION 1.22.19

RUN apk add --no-cache --virtual .build-deps-yarn curl gnupg tar \
# use pre-existing gpg directory, see https://github.com/nodejs/docker-node/pull/1895#issuecomment-1550389150
&& export GNUPGHOME="$(mktemp -d)" \
&& for key in \
6A010C5166006599AA17F08146C2130DFD2497F5 \
; do \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys "$key" || \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key" ; \
done \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
&& curl -fsSLO --compressed "https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc" \
&& gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& gpgconf --kill all \
&& rm -rf "$GNUPGHOME" \
&& mkdir -p /opt \
&& tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \
&& ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \
&& rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz \
&& apk del .build-deps-yarn \
# smoke test
&& yarn --version

RUN apk --no-cache add gettext git htop tree linux-headers libc-dev

# Install Rust
RUN apk --no-cache add rust rust-wasm cargo
RUN cargo install cargo-wasi --root=/usr/local
RUN chmod 777 /usr/local/bin

COPY base.makefile Makefile shopify-app.md /assets/
COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT ["entrypoint.sh"]
File renamed without changes.
4 changes: 2 additions & 2 deletions shopify/Dockerfile → shopify/n18.19.0/p8.1/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.3-cli-alpine3.17
FROM php:8.1-cli-alpine3.20

ARG XDEBUG_CLIENT_HOST=host.docker.internal
ENV XDEBUG_CLIENT_HOST $XDEBUG_CLIENT_HOST
Expand Down Expand Up @@ -165,4 +165,4 @@ RUN chmod 777 /usr/local/bin

COPY base.makefile Makefile shopify-app.md /assets/
COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT ["entrypoint.sh"]
ENTRYPOINT ["entrypoint.sh"]
15 changes: 15 additions & 0 deletions shopify/n18.19.0/p8.1/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include base.makefile

# Add additional targets here or extend(::)/override(:) some, e.g.:

# New target
#install-my-project: ## description for install-my-project
# @echo project installation steps

# Extend: Further init directories
#init-directories::
# @[ -d ~/dir ] || mkdir ~/dir

# Override: New Node.js installation steps
#install-nodejs:
# @echo install it some other way
Loading

0 comments on commit c048156

Please sign in to comment.