Skip to content

Commit

Permalink
Add template to generate docker based on a branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Oct 29, 2024
1 parent c95a5bc commit 3cba55c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Dockerfile-branch.model
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM prestashop/base:$container_version
LABEL maintainer="PrestaShop Core Team <[email protected]>"

RUN apt update
RUN apt -y install git

RUN git clone -b $ps_version https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps

CMD ["/tmp/docker_run.sh"]
3 changes: 2 additions & 1 deletion prestashop_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def main():
generator = Generator(
path.join(path.dirname(path.realpath(__file__)), 'images'),
open('./Dockerfile.model').read(),
open('./Dockerfile-nightly.model').read()
open('./Dockerfile-nightly.model').read(),
open('./Dockerfile-branch.model').read()
)
generator.generate_all(VERSIONS)
elif args.subcommand == 'tag':
Expand Down
7 changes: 6 additions & 1 deletion prestashop_docker/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Generator:
NIGHTLY = 'nightly'

def __init__(self, directory_path, template, nightly_template):
def __init__(self, directory_path, template, nightly_template, branch_template):
"""Constructor
@param directory_path: Directory path
Expand All @@ -17,13 +17,16 @@ def __init__(self, directory_path, template, nightly_template):
@type template: str
@param nightly_template: Nightly template
@type nightly_template: str
@param branch_template: Branch template
@type branch_template: str
"""
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.directory_path = directory_path
self.template = Template(template)
self.nightly_template = Template(nightly_template)
self.branch_template = Template(branch_template)

def create_directory(self, directory_path):
"""Try to create a directory if it's possible
Expand Down Expand Up @@ -57,6 +60,8 @@ def generate_image(self, ps_version, container_version):
file_path = path.join(directory_path, 'Dockerfile')
template = self.nightly_template if (
ps_version == self.NIGHTLY
) else self.branch_template if (
ps_version.endswith('.x')
) else self.template

with open(file_path, 'w+') as f:
Expand Down
5 changes: 5 additions & 0 deletions versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@
'8.0',
'8.1',
),
'9.0.x': (
'8.1',
'8.2',
'8.3',
),
'nightly': (
'8.1',
'8.2',
Expand Down

0 comments on commit 3cba55c

Please sign in to comment.