Skip to content

Commit

Permalink
chore(docker): Handle classic image generation and generate for beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
tleon committed Feb 10, 2025
1 parent 52b92f6 commit fcf91c8
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 11 deletions.
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.1-apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.1-apache
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.1-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.1-fpm
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.2-apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.2-apache
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.2-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.2-fpm
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.3-apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.3-apache
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.3-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.3-fpm
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.4-apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.4-apache
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
13 changes: 13 additions & 0 deletions images/9.0.0-beta.1-classic/8.4-fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM prestashop/base:8.4-fpm
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ENV PS_VERSION 9.0.0-beta.1-classic

# Get PrestaShop
ADD https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/9.0.0-beta.1-classic/prestashop_9.0.0-beta.1-classic.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
6 changes: 5 additions & 1 deletion prestashop_docker/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, directory_path, template, nightly_template, branch_template):
self.download_url = 'https://www.prestashop.com/download/old/' \
'prestashop_{}.zip'
self.download_url_github = 'https://github.com/PrestaShop/PrestaShop/releases/download/{}/prestashop_{}.zip'
self.download_url_github_classic = 'https://github.com/PrestaShopCorp/PrestaShop-classic/releases/download/{}/prestashop_{}.zip'
self.directory_path = directory_path
self.template = Template(template)
self.nightly_template = Template(nightly_template)
Expand Down Expand Up @@ -92,7 +93,10 @@ def generate_image(self, ps_version, container_version):
use_github_url = False

if use_github_url:
ps_url = self.download_url_github.format(ps_version, ps_version)
if parsed_version['flavor_versions'] == 'classic':
ps_url = self.download_url_github_classic.format(ps_version, ps_version)
else:
ps_url = self.download_url_github.format(ps_version, ps_version)
else:
ps_url = self.download_url.format(ps_version)
f.write(
Expand Down
15 changes: 11 additions & 4 deletions prestashop_docker/version_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ def get_version_from_string(self, version):
@param version: The version you want
@type version: str
@return: A tuple containing ('PS_VERSION', 'BRANCH_VERSION', (PHP_VERSIONS), 'CONTAINER_TYPE')
or ('PS_VERSION', 'BRANCH_VERSION', 'PHP_VERSION', 'CONTAINER_TYPE')
@return: A tuple containing ('PS_VERSION', 'BRANCH_VERSION', (PHP_VERSIONS), 'CONTAINER_TYPE', 'FLAVOR_VERSION')
or ('PS_VERSION', 'BRANCH_VERSION', 'PHP_VERSION', 'CONTAINER_TYPE', 'FLAVOR_VERSION')
@rtype: tuple
'''
matches = self.parse_version_from_string(version)
if not matches:
return None

ps_version = matches.group('version')

flavor_versions = None
if matches.group('flavor'):
flavor_versions = matches.group('flavor')
ps_version = ps_version + '-' + flavor_versions

if matches.group('php'):
php_versions = (matches.group('php'),)
else:
Expand Down Expand Up @@ -140,7 +146,8 @@ def get_version_from_string(self, version):
'ps_version': ps_version,
'branch_version': branch_version,
'php_versions': php_versions,
'container_version': container_version
'container_version': container_version,
'flavor_versions': flavor_versions
}

def get_last_patch_from_version(self, version):
Expand Down Expand Up @@ -201,7 +208,7 @@ def parse_version_from_string(self, version):
@return: Return None if no position in the string matches the pattern otherwise a Match object.
@rtpe: None|Match
'''
regex = r"^(?P<version>(?:[0-9]+\.){0,3}(?:[0-9]+|nightly|x)(?:-(?:alpha|beta|rc)(?:\.\d+)?(?:\+\d+)?)?)(?:-(?P<php>\d+\.\d+))?(?:-(?P<container>fpm|apache))?$"
regex = r"^(?P<version>(?:[0-9]+\.){0,3}(?:[0-9]+|nightly|x)(?:-(?:alpha|beta|rc)(?:\.\d+)?(?:\+\d+)?)?)(?:-(?P<flavor>classic))?(?:-(?P<php>\d+\.\d+))?(?:-(?P<container>fpm|apache))?$"
return re.search(regex, version)

def get_aliases(self):
Expand Down
18 changes: 12 additions & 6 deletions tests/prestashop_docker/test_version_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,35 +141,41 @@ def test_get_version_from_string_with_ps_version(self):
# Existing patch versions deduce the branch version with a finishing x
result = self.version_manager.get_version_from_string('1.7.6.8')
self.assertEqual(
{'ps_version': '1.7.6.8', 'branch_version': '1.7.6.x', 'php_versions': ('5.6', '7.1', '7.2'), 'container_version': None},
{'ps_version': '1.7.6.8', 'branch_version': '1.7.6.x', 'php_versions': ('5.6', '7.1', '7.2'), 'container_version': None, 'flavor_versions': None},
result
)
result = self.version_manager.get_version_from_string('8.0.0')
self.assertEqual(
{'ps_version': '8.0.0', 'branch_version': '8.0.x', 'php_versions': ('7.2', '7.3', '7.4', '8.0', '8.1'), 'container_version': None},
{'ps_version': '8.0.0', 'branch_version': '8.0.x', 'php_versions': ('7.2', '7.3', '7.4', '8.0', '8.1'), 'container_version': None, 'flavor_versions': None},
result
)
# Branch input return target version patch + 1
result = self.version_manager.get_version_from_string('8.1.x')
self.assertEqual(
{'ps_version': '8.1.4', 'branch_version': '8.1.x', 'php_versions': ('7.2', '7.3', '7.4', '8.0', '8.1'), 'container_version': None},
{'ps_version': '8.1.4', 'branch_version': '8.1.x', 'php_versions': ('7.2', '7.3', '7.4', '8.0', '8.1'), 'container_version': None, 'flavor_versions': None},
result
)
result = self.version_manager.get_version_from_string('1.7.6.x')
self.assertEqual(
{'ps_version': '1.7.6.25', 'branch_version': '1.7.6.x', 'php_versions': ('5.6', '7.1', '7.2'), 'container_version': None},
{'ps_version': '1.7.6.25', 'branch_version': '1.7.6.x', 'php_versions': ('5.6', '7.1', '7.2'), 'container_version': None, 'flavor_versions': None},
result
)
# Branch input with no other patch versions returns patch 0
result = self.version_manager.get_version_from_string('9.0.x')
self.assertEqual(
{'ps_version': '9.0.0', 'branch_version': '9.0.x', 'php_versions': ('8.1', '8.2', '8.3'), 'container_version': None},
{'ps_version': '9.0.0', 'branch_version': '9.0.x', 'php_versions': ('8.1', '8.2', '8.3'), 'container_version': None, 'flavor_versions': None},
result
)
# Branch input with classic
result = self.version_manager.get_version_from_string('9.0.0-classic')
self.assertEqual(
{'ps_version': '9.0.0', 'branch_version': '9.0.x', 'php_versions': ('8.1', '8.2', '8.3'), 'container_version': None, 'flavor_versions': 'classic'},
result
)
# Nightly version uses develop as the branch
result = self.version_manager.get_version_from_string('nightly')
self.assertEqual(
{'ps_version': 'nightly', 'branch_version': 'develop', 'php_versions': ('7.1', '7.2', '7.3'), 'container_version': None},
{'ps_version': 'nightly', 'branch_version': 'develop', 'php_versions': ('7.1', '7.2', '7.3'), 'container_version': None, 'flavor_versions': None},
result
)

Expand Down
6 changes: 6 additions & 0 deletions versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@
'8.3',
'8.4',
),
'9.0.0-beta.1-classic': (
'8.1',
'8.2',
'8.3',
'8.4',
),
'nightly': (
'8.1',
'8.2',
Expand Down

0 comments on commit fcf91c8

Please sign in to comment.