Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): add a cron job every night at 2 to publish the nightly #78

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/nightly-cron-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: E2E

on:
schedule:
- cron: "2 0 * * *"
workflow_dispatch:
workflow_call:

jobs:
build_and_publish:
name: Build and publish docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ env.TARGET_PLATFORM }}
use: true

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push ${{ inputs.ps_version }} ${{ inputs.os_flavour }}
run: ./build.sh
env:
TARGET_PLATFORM: "linux/amd64,linux/arm64"
PS_VERSION: "nightly"
PUSH: "true"
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Some tags may not be built yet, feel free to [fill an issue](./issues) to reques

PrestaShop Flashlight can be used as a **development environment**, a **CI/CD asset** to build up a custom PrestaShop environment, or any use case you can think of. Following is a list of resources and examples to get you started:

- [Basic Example](./examples/basic-example/)
- [Basic example](./examples/basic-example/)
- [Nightly example](./examples/nightly-example/)
- [Develop PrestaShop](./examples/develop-prestashop/)
- [Develop a PrestaShop Module](./examples/develop-a-module/)
- [Custom init-scripts](./examples/with-init-scripts/)
Expand All @@ -55,7 +56,7 @@ You can check this implementation anytime in [prestashop-version.json](./prestas
## Environment variables

| Variable | Description | Required | Default value |
|----------------------------|----------------------------------------------------------------------------------------------------------|----------------------------------------------|---------------------------------------|
| -------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------- |
| PS_DOMAIN | the public domain (and port) to reach your PrestaShop instance | yes, unless using `NGROK_TUNNEL_AUTO_DETECT` | N/A (example: `localhost:8000`) |
| NGROK_TUNNEL_AUTO_DETECT | the ngrok agent base API url, to guess the tunnel domain of your shop | yes, unless using `PS_DOMAIN` | N/A (example `http://ngrok:4040`) |
| SSL_REDIRECT | if enabled and using PS_DOMAIN, PrestaShop will redirect all inbound traffic to `https://$PS_DOMAIN` | no | `false` (example: `true`) |
Expand All @@ -80,7 +81,7 @@ You can check this implementation anytime in [prestashop-version.json](./prestas
The default url/credentials to access to PrestaShop's back office defined in [`./assets/hydrate.sh`](./assets/hydrate.sh) and are set to:

| Url | {PS_DOMAIN}/admin-dev |
|----------|-----------------------|
| -------- | --------------------- |
| Login | admin@prestashop.com |
| Password | prestashop |

Expand All @@ -89,7 +90,7 @@ The default url/credentials to access to PrestaShop's back office defined in [`.
On error, PrestaShop Flashlight can quit with these exit codes:

| Exit Code | Description |
|-----------|----------------------------------------------------------------------------------|
| --------- | -------------------------------------------------------------------------------- |
| 0 | graceful exit, probably running dry mode or after a SIGKILL |
| 1 | reserved for nginx |
| 2 | Missing $PS_DOMAIN or $NGROK_TUNNEL_AUTO_DETECT |
Expand Down
29 changes: 18 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,26 @@ get_target_images() {
local PHP_VERSION=${3:-};
local OS_FLAVOUR=${4:-};
declare RES;

if [ "$PS_VERSION" = "$(get_latest_prestashop_version)" ] && [ "$OS_FLAVOUR" = "$DEFAULT_OS" ] && [ "$PHP_VERSION" = "$(get_recommended_php_version "$PS_VERSION")" ]; then
RES="-t ${DEFAULT_DOCKER_IMAGE}:latest";
fi
if [ "$OS_FLAVOUR" = "$DEFAULT_OS" ]; then
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${PHP_VERSION}";
if [ "$PHP_VERSION" = "$(get_recommended_php_version "$PS_VERSION")" ]; then
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}";
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:php-${PHP_VERSION}";
if [ "$PS_VERSION" == "nightly" ]; then
if [ "$OS_FLAVOUR" = "$DEFAULT_OS" ]; then
RES="-t ${DEFAULT_DOCKER_IMAGE}:nightly";
else
RES="-t ${DEFAULT_DOCKER_IMAGE}:nightly-${OS_FLAVOUR}";
fi
else
if [ "$PS_VERSION" = "$(get_latest_prestashop_version)" ] && [ "$OS_FLAVOUR" = "$DEFAULT_OS" ] && [ "$PHP_VERSION" = "$(get_recommended_php_version "$PS_VERSION")" ]; then
RES="-t ${DEFAULT_DOCKER_IMAGE}:latest";
fi
if [ "$OS_FLAVOUR" = "$DEFAULT_OS" ]; then
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${PHP_VERSION}";
if [ "$PHP_VERSION" = "$(get_recommended_php_version "$PS_VERSION")" ]; then
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}";
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:php-${PHP_VERSION}";
fi
fi
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${PHP_FLAVOUR}";
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${OS_FLAVOUR}";
fi
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${PHP_FLAVOUR}";
RES="${RES} -t ${DEFAULT_DOCKER_IMAGE}:${PS_VERSION}-${OS_FLAVOUR}";
echo "$RES";
}

Expand Down
5 changes: 3 additions & 2 deletions examples/basic-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ You can access to PrestaShop in your browser:
If you want to start a phpMyAdmin instance, it can be done easily like so:

```sh
docker compose up # or "docker compose up prestashop php-my-admin"
docker compose up
# or "docker compose up prestashop php-my-admin"
```

Now you can access phpMyAdmin at http://localhost:6060
You can now access phpMyAdmin at http://localhost:6060
27 changes: 27 additions & 0 deletions examples/nightly-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Example: nightly example

This example runs the latest nightly image of PrestaShop Flashlight, which is based on the latest nightly of PrestaShop. There might be bugs in a nightly, be cautious when using this image in your CI/CD toolchain.

## Test this example

The expected output of this example is:

```sh
docker compose up prestashop --force-recreate
```

You can access to PrestaShop in your browser:

- http://localhost:8000
- http://localhost:8000/admin-dev/ (back office, login/password described [here](../../README.md))

## Running phpMyAdmin

If you want to start a phpMyAdmin instance, it can be done easily like so:

```sh
docker compose up
# or "docker compose up prestashop php-my-admin"
```

You can now access phpMyAdmin at http://localhost:6060
54 changes: 54 additions & 0 deletions examples/nightly-example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: flashlight-basic-example
services:
prestashop:
image: prestashop/prestashop-flashlight:nightly
depends_on:
mysql:
condition: service_healthy
environment:
- PS_DOMAIN=localhost:8000
# - DEBUG_MODE=true
ports:
- 8000:80

mysql:
image: mariadb:lts
healthcheck:
test:
[
"CMD",
"mysqladmin",
"ping",
"--host=localhost",
"--user=root",
"--password=prestashop",
]
interval: 10s
timeout: 10s
retries: 5
environment:
- MYSQL_HOST=mysql
- MYSQL_USER=prestashop
- MYSQL_PASSWORD=prestashop
- MYSQL_ROOT_PASSWORD=prestashop
- MYSQL_PORT=3306
- MYSQL_DATABASE=prestashop

phpmyadmin:
image: phpmyadmin:latest
depends_on:
mysql:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-Isf", "http://localhost/robots.txt"]
interval: 30s
timeout: 10s
retries: 5
environment:
- PMA_HOST=mysql
- PMA_PORT=3306
- PMA_USER=prestashop
- PMA_PASSWORD=prestashop
- MYSQL_ROOT_PASSWORD=prestashop
ports:
- 6060:80