diff --git a/Dockerfile-branch.model b/Dockerfile-branch.model new file mode 100644 index 00000000..5cd6ff87 --- /dev/null +++ b/Dockerfile-branch.model @@ -0,0 +1,9 @@ +FROM prestashop/base:$container_version +LABEL maintainer="PrestaShop Core Team " + +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"] diff --git a/images/9.0.x/8.1-apache/Dockerfile b/images/9.0.x/8.1-apache/Dockerfile new file mode 100644 index 00000000..a97ee5c8 --- /dev/null +++ b/images/9.0.x/8.1-apache/Dockerfile @@ -0,0 +1,9 @@ +FROM prestashop/base:8.1-apache +LABEL maintainer="PrestaShop Core Team " + +RUN apt update +RUN apt -y install git + +RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps + +CMD ["/tmp/docker_run.sh"] diff --git a/images/9.0.x/8.1-fpm/Dockerfile b/images/9.0.x/8.1-fpm/Dockerfile new file mode 100644 index 00000000..2edd2246 --- /dev/null +++ b/images/9.0.x/8.1-fpm/Dockerfile @@ -0,0 +1,9 @@ +FROM prestashop/base:8.1-fpm +LABEL maintainer="PrestaShop Core Team " + +RUN apt update +RUN apt -y install git + +RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps + +CMD ["/tmp/docker_run.sh"] diff --git a/images/9.0.x/8.2-apache/Dockerfile b/images/9.0.x/8.2-apache/Dockerfile new file mode 100644 index 00000000..cb01b49b --- /dev/null +++ b/images/9.0.x/8.2-apache/Dockerfile @@ -0,0 +1,9 @@ +FROM prestashop/base:8.2-apache +LABEL maintainer="PrestaShop Core Team " + +RUN apt update +RUN apt -y install git + +RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps + +CMD ["/tmp/docker_run.sh"] diff --git a/images/9.0.x/8.2-fpm/Dockerfile b/images/9.0.x/8.2-fpm/Dockerfile new file mode 100644 index 00000000..4b042509 --- /dev/null +++ b/images/9.0.x/8.2-fpm/Dockerfile @@ -0,0 +1,9 @@ +FROM prestashop/base:8.2-fpm +LABEL maintainer="PrestaShop Core Team " + +RUN apt update +RUN apt -y install git + +RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps + +CMD ["/tmp/docker_run.sh"] diff --git a/images/9.0.x/8.3-apache/Dockerfile b/images/9.0.x/8.3-apache/Dockerfile new file mode 100644 index 00000000..094eed98 --- /dev/null +++ b/images/9.0.x/8.3-apache/Dockerfile @@ -0,0 +1,9 @@ +FROM prestashop/base:8.3-apache +LABEL maintainer="PrestaShop Core Team " + +RUN apt update +RUN apt -y install git + +RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps + +CMD ["/tmp/docker_run.sh"] diff --git a/images/9.0.x/8.3-fpm/Dockerfile b/images/9.0.x/8.3-fpm/Dockerfile new file mode 100644 index 00000000..feb3eba4 --- /dev/null +++ b/images/9.0.x/8.3-fpm/Dockerfile @@ -0,0 +1,9 @@ +FROM prestashop/base:8.3-fpm +LABEL maintainer="PrestaShop Core Team " + +RUN apt update +RUN apt -y install git + +RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps + +CMD ["/tmp/docker_run.sh"] diff --git a/images/nightly/7.2-apache/Dockerfile b/images/nightly/7.2-apache/Dockerfile deleted file mode 100644 index c1e2f19a..00000000 --- a/images/nightly/7.2-apache/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:7.2-apache -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/images/nightly/7.2-fpm/Dockerfile b/images/nightly/7.2-fpm/Dockerfile deleted file mode 100644 index f72589c9..00000000 --- a/images/nightly/7.2-fpm/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:7.2-fpm -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/images/nightly/7.3-apache/Dockerfile b/images/nightly/7.3-apache/Dockerfile deleted file mode 100644 index 5b30a624..00000000 --- a/images/nightly/7.3-apache/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:7.3-apache -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/images/nightly/7.3-fpm/Dockerfile b/images/nightly/7.3-fpm/Dockerfile deleted file mode 100644 index 6cfc8385..00000000 --- a/images/nightly/7.3-fpm/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:7.3-fpm -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/images/nightly/7.4-apache/Dockerfile b/images/nightly/7.4-apache/Dockerfile deleted file mode 100644 index 733b8552..00000000 --- a/images/nightly/7.4-apache/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:7.4-apache -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/images/nightly/7.4-fpm/Dockerfile b/images/nightly/7.4-fpm/Dockerfile deleted file mode 100644 index f4ce0d97..00000000 --- a/images/nightly/7.4-fpm/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:7.4-fpm -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/images/nightly/8.0-apache/Dockerfile b/images/nightly/8.0-apache/Dockerfile deleted file mode 100644 index 8320fe58..00000000 --- a/images/nightly/8.0-apache/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:8.0-apache -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/images/nightly/8.0-fpm/Dockerfile b/images/nightly/8.0-fpm/Dockerfile deleted file mode 100644 index e1613c81..00000000 --- a/images/nightly/8.0-fpm/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM prestashop/base:8.0-fpm -LABEL maintainer="PrestaShop Core Team " - -ENV PS_VERSION nightly - -ENV PATH /root/google-cloud-sdk/bin/:$PATH - -RUN apt update -RUN apt -y install \ - python3 \ - curl \ - bash - -RUN curl -sSL https://sdk.cloud.google.com | bash -RUN gcloud config set core/disable_usage_reporting true && \ - gcloud config set component_manager/disable_update_check true && \ - gcloud config set metrics/environment github_docker_image && \ - gcloud --version - -CMD ["/tmp/docker_nightly_run.sh"] diff --git a/prestashop_docker.py b/prestashop_docker.py index 3e91eddc..032a2586 100755 --- a/prestashop_docker.py +++ b/prestashop_docker.py @@ -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': diff --git a/prestashop_docker/generator.py b/prestashop_docker/generator.py index db253b5e..b272e19a 100644 --- a/prestashop_docker/generator.py +++ b/prestashop_docker/generator.py @@ -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 @@ -17,6 +17,8 @@ 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' @@ -24,6 +26,7 @@ def __init__(self, directory_path, template, nightly_template): 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 @@ -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: diff --git a/tests/prestashop_docker/test_generator.py b/tests/prestashop_docker/test_generator.py index 215fd59f..61a22955 100644 --- a/tests/prestashop_docker/test_generator.py +++ b/tests/prestashop_docker/test_generator.py @@ -24,11 +24,20 @@ def setUp(self): CONTAINER_VERSION: $container_version ''' ) + self.fs.create_file( + 'Dockerfile-branch.model', + contents=''' + CONTAINER_VERSION: $container_version + RUN apt -y install git + RUN git clone -b $ps_version https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps + ''' + ) self.generator = Generator( '/tmp/images', open('Dockerfile.model').read(), - open('Dockerfile-nightly.model').read() + open('Dockerfile-nightly.model').read(), + open('Dockerfile-branch.model').read() ) def test_create_directory(self): @@ -92,6 +101,26 @@ def test_generate_nightly_image(self): self.assertIn('PS_VERSION: nightly', content) self.assertIn('CONTAINER_VERSION: 7.2-alpine', content) + def test_generate_branch_image(self): + dockerfile = '/tmp/images/9.0.x/8.1-alpine/Dockerfile' + self.assertFalse(path.exists(dockerfile)) + self.generator.generate_image( + '9.0.x', + '8.1-alpine' + ) + self.assertTrue(path.exists(dockerfile)) + + with open(dockerfile) as f: + content = f.read() + self.assertNotIn( + 'PS_URL', + content + ) + self.assertNotIn('PS_VERSION', content) + self.assertIn('CONTAINER_VERSION: 8.1-alpine', content) + self.assertIn('RUN apt -y install git', content) + self.assertIn('RUN git clone -b 9.0.x https://github.com/PrestaShop/PrestaShop.git /tmp/data-ps', content) + def test_generate_all(self): files = ( '/tmp/images/7.0/7.3-apache/Dockerfile', diff --git a/versions.py b/versions.py index c7d2bab8..0456f74f 100644 --- a/versions.py +++ b/versions.py @@ -261,6 +261,11 @@ '8.0', '8.1', ), + '9.0.x': ( + '8.1', + '8.2', + '8.3', + ), 'nightly': ( '8.1', '8.2',