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

feat(major): Add Debian support #10

Merged
merged 54 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a888de5
WIP
jokesterfr Oct 11, 2023
2cd608f
Fix build script
jokesterfr Oct 12, 2023
d1c22b0
Fix paths
jokesterfr Oct 12, 2023
0c5c4f5
Enhance documentation and support
jokesterfr Oct 12, 2023
d38fa1d
Ignore local modules dir
jokesterfr Oct 12, 2023
569c7f8
Fix up debian release dependant script
jokesterfr Oct 12, 2023
02d1b5c
Pipefail not yet supported on debian sh
jokesterfr Oct 12, 2023
262170d
Add a pr github action workflow
jokesterfr Oct 12, 2023
f64bfbe
Enhance documentation and lint
jokesterfr Oct 12, 2023
2615ae3
Add hadolint support in github action
jokesterfr Oct 12, 2023
999a43a
Clarify php flavours
jokesterfr Oct 12, 2023
75a67f7
Test it out
jokesterfr Oct 12, 2023
78e8115
A bit better
jokesterfr Oct 12, 2023
fd8911a
Fix build and lint
jokesterfr Oct 12, 2023
aeada28
Add build test in CI
jokesterfr Oct 12, 2023
f6614ee
checkout was missing
jokesterfr Oct 12, 2023
c178811
Testing
jokesterfr Oct 12, 2023
e360efb
Quick fix
jokesterfr Oct 12, 2023
9948799
Update basic tools
jokesterfr Oct 12, 2023
881aa9e
Update docker/debian.Dockerfile
jokesterfr Oct 13, 2023
3ef1cc9
Update docker/debian.Dockerfile
jokesterfr Oct 13, 2023
936a31a
Update php-flavours.json
jokesterfr Oct 13, 2023
1537d6f
Switch to a table
jokesterfr Oct 13, 2023
ddf354a
Remove useless clean
jokesterfr Oct 13, 2023
9c92337
ci: Update actions
Venatum Oct 17, 2023
34e4792
fix: Mysql & php upload size
Venatum Oct 18, 2023
e938afd
A more generic mysql configuration
jokesterfr Oct 24, 2023
eab2d8c
swap from runuser to a more generic sudo
jokesterfr Oct 25, 2023
4eeeb76
Better configuration of gd
jokesterfr Oct 25, 2023
e01e345
Installation with error logs if any and avoid bin/console issue on PS1.6
jokesterfr Oct 25, 2023
d5b1930
New version dimension to the CI Matrix
jokesterfr Oct 25, 2023
c246b62
Fix linting issue
jokesterfr Oct 25, 2023
e066a50
Merge branch 'main' into fea/debian-flavour
jokesterfr Oct 25, 2023
92792fc
Handle both php7.1 and upper
jokesterfr Oct 25, 2023
0b6999e
Merge branch 'toto' into fea/debian-flavour
jokesterfr Oct 25, 2023
3078145
Try again
jokesterfr Oct 25, 2023
f9da2c5
Lint fix
jokesterfr Oct 25, 2023
36822eb
fix
jokesterfr Oct 25, 2023
a89da80
Fixes it all back again
jokesterfr Oct 25, 2023
a4e8371
d
jokesterfr Oct 25, 2023
e7b5eb1
Adds dry run mode
jokesterfr Oct 25, 2023
ef2ccf9
Should make this all work hopefully
jokesterfr Oct 25, 2023
a1c0ec4
Naming accuracy
jokesterfr Oct 25, 2023
196dcc6
Adds an extra tag
jokesterfr Oct 25, 2023
7383fa5
Dry run testing FTW
jokesterfr Oct 25, 2023
80c34a9
Cosmetic
jokesterfr Oct 25, 2023
f64d112
Last bafouille
jokesterfr Oct 25, 2023
f459418
attempt
jokesterfr Oct 26, 2023
132e9bb
Fix multiline
jokesterfr Oct 26, 2023
31166bb
Enhance env
jokesterfr Oct 26, 2023
428e5b8
Add mention for PS 1.6
jokesterfr Oct 26, 2023
b5537d9
Disclaimer notice on 1.6
jokesterfr Oct 26, 2023
6ea71d5
Patch 1.6 FTW
jokesterfr Oct 26, 2023
c96c8e8
lint bim
jokesterfr Oct 26, 2023
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: 22 additions & 20 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ on:
tags: ["v*.*.*"]
workflow_dispatch:
inputs:
# flavour:
# description: 'PrestaShop flavour'
# required: true
# default: 'alpine'
# type: choice
# options:
# - debian
# - alpine
# server:
# description: 'PrestaShop server'
# required: true
# default: 'nginx'
# type: choice
# options:
# - nginx
# - apache
flavour:
description: "OS flavour"
required: false
default: "alpine"
type: choice
options:
- alpine
- debian

server:
description: "Server flavour"
required: false
default: "nginx"
type: choice
options:
- nginx
- apache

ps_version:
description: "The target PrestaShop version (defaults to 'latest')"
required: false
Expand Down Expand Up @@ -56,16 +58,16 @@ jobs:
uses: actions/checkout@v4

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

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

- name: Login to Docker Hub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -77,4 +79,4 @@ jobs:
PS_VERSION: ${{ inputs.ps_version }}
PHP_VERSION: ${{ inputs.php_version }}
TAG: ${{ inputs.tag }}
PUSH: true
PUSH: "true"
45 changes: 45 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Pull Request
on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
lint_shell:
name: "Lint: shell"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

lint_dockerfile:
name: "Lint: dockerfile"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
with:
recursive: true
dockerfile: "*.Dockerfile"

docker_build:
name: "Docker build: ${{ matrix.os_flavour }} for ${{ matrix.ps_version }}"
runs-on: ubuntu-latest
strategy:
matrix:
os_flavour: ["alpine", "debian"]
ps_version: ["1.6.1.24", "1.7.8.10", "8.1.1"]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Call the docker build chain
run: ./build.sh
env:
OS_FLAVOUR: ${{ matrix.os_flavour }}
PS_VERSION: ${{ matrix.ps_version }}

- name: Test the image with a dry run
run: docker run --env PS_DOMAIN='localhost:80' --env DRY_RUN='true' $DOCKER_IMAGE
env:
DOCKER_IMAGE: prestashop/prestashop-flashlight:${{ matrix.ps_version }}-${{ matrix.os_flavour }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.DS_Store
.*.swp
*.sql
modules/

# Sonar
.scannerwork
Expand Down
7 changes: 7 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ignored:
- DL3006
- DL3008
- DL3009
- DL3018
- DL4006
- SC1091
133 changes: 64 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,34 @@

Spin a Prestashop testing instance in seconds!

> **⚠️ Disclaimer**: the following tool is provided in the sole purpose of bootstraping a PrestaShop testing environment. <br>If you look for a production grade image, please refer to https://github.com/PrestaShop/docker.

> **Note**: no MySQL server is shipped in the resulting image, you have to provide your own instance for the backup to be dumped during the first connection.
PrestaShop Flashlight is fast: the installation process with default content for a PrestaShop is tackled at build time, compiling the result to a single database dump.

Compatible with these architecture:
Supported architectures:

- linux/amd64 (akka `x86_64`)
- linux/arm64/v8 (akka `arm64`)

The resulting image is based on this tech stack:

- An [Alpine](https://www.alpinelinux.org/) linux image
- An [Nginx](https://www.nginx.com/) server
At runtime the dump is tweaked and consumed, providing a fast instance bootstrap.

## How fast is it?

On a Mac M1 (_linux/arm64_) computer:

```
❯ docker compose up -d
[+] Building 0.0s (0/0)
[+] Running 3/3
✔ Container phpmyadmin Running 0.0s
✔ Container mysql Healthy 10.8s
✔ Container prestashop Started 11.1s
```
> **⚠️ Disclaimer**: the following tool is provided in the sole purpose of bootstraping a PrestaShop testing environment. <br>If you look for a production grade image, please refer to https://github.com/PrestaShop/docker.

VS the official production image (_linux/amd64_ only) with `AUTO_INSTALL=1`: 2mn 15s.
> **Note**: no MySQL server is shipped in the resulting image, you have to provide your own instance for the backup to be dumped during the first connection.

## Where do I find pre-built images?

Here: https://hub.docker.com/r/prestashop/prestashop-flashlight

## Use

Start the environment
Start the environment:

```sh
cp .env.dist .env
edit .env
docker compose up
```

Add init scripts
You can also tweak the provided `docker-compose.yml` file, and for example, add init scripts:

```yaml
services:
Expand All @@ -55,10 +39,31 @@ services:
- ./init-scripts:/tmp/init-scripts:ro
```

| **⚠️ Note:** your scripts **MUST** be executable, and have a [shebang](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) to be run by flashlight at startup. Otherwise they would be ignored.

## Run environment variables

| Variable | Description | Required | Default value |
| -------------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------- |
| PS_DOMAIN | the public domain (and port) to reach your PrestaShop instance | yes, unles 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`) |
| DEBUG_MODE | if enabled the Debug mode will be enabled on PrestaShop | no | `false` |
| INSTALL_MODULES_DIR | module directory containing zips to be installed with the PrestaShop CLI | no | empty string (example: `/ps-modules`) |
| INIT_ON_RESTART | if enabled the PS_DOMAIN auto search and dump fix will be replayed on container restart | no | `false` |
| DUMP_ON_RESTART | if enabled the dump restoration replayed on container restart | no | `false` |
| INSTALL_MODULES_ON_RESTART | if enabled zip modules will be reinstalled on container restart | no | `false` |
| INIT_SCRIPTS_ON_RESTART | if enabled custom init scripts will be replayed on container restart | no | `false` |
| ON_INIT_SCRIPT_FAILURE | if set to `continue`, PrestaShop Flashlight will continue the boot process even if an init script failed | no | `fail` |
| DRY_RUN | if enabled, the run.sh script will exit without really starting a web server | no | `false` |

# Develop

## Build

Requirements:
* [jq](https://jqlang.github.io/jq/)

- [jq](https://jqlang.github.io/jq/)

To build the latest PrestaShop version, simply:

Expand All @@ -76,53 +81,43 @@ TARGET_IMAGE=my-own-repo/testing:latest \
./build.sh
```

## Container environment variables

- **`PS_DOMAIN`**
- Description: the public domain (and port) to reach your PrestaShop instance
- Mandatory if you do not use `NGROK_TUNNEL_AUTO_DETECT`
- Example: `localhost:8000`
- **`NGROK_TUNNEL_AUTO_DETECT`**
- Description: the ngrok agent base API url, to guess the tunnel domain of your shop
- Mandatory if you do not use `PS_DOMAIN`
- Example: `http://ngrok:4040`
- **`SSL_REDIRECT`**
- If set to `true` PrestaShop will be told to redirect all inbound traffic to https://$PS_DOMAIN
- Default to `false` (or automatically guessed if using NGROK_TUNNEL_AUTO_DETECT)
- **`DEBUG_MODE`**
- If set to `true` the Debug mode will be enabled on PrestaShop
- Default to `false`
- **`INSTALL_MODULES_DIR`**
- A module directory containing zips to be installed with the PrestaShop CLI
- Example: `/ps-modules`
- **`INIT_ON_RESTART`**
- If set to `true` the PS_DOMAIN auto search and dump fix will be replayed on container restart
- Default to `false`
- **`DUMP_ON_RESTART`**
- If set to `true` the dump restoration replayed on container restart
- Default to `false`
- **`INSTALL_MODULES_ON_RESTART`**
- If set to `true` zip modules will be reinstalled on container restart
- Default to `false`
- **`INIT_SCRIPTS_ON_RESTART`**
- If set to `true` custom init scripts will be replayed on container restart
- Default to `false`
- **`ON_INIT_SCRIPT_FAILURE`**
- If set to `continue`, PrestaShop Flashlight will continue the boot process even if an init script failed
- Default to `fail`

## Back office access informations

The default url/credentials to access back office are defined in `assets/hydrate.sh` and are set to:

| Url | {PS_DOMAIN}/ps-admin|
| --- | --- |
| Login | admin@prestashop.com |
| Password | prestashop |
The `OS_FLAVOUR` defaults to `alpine` (see [Alpine Linux](https://www.alpinelinux.org/)) and `SERVER_FLAVOUR` to `nginx` (see [Nginx](https://www.nginx.com/)).
jokesterfr marked this conversation as resolved.
Show resolved Hide resolved

For more documentation about available build variables, please see [./build.sh](./build.sh).

## Lint

Requirements:

- [shellcheck](https://github.com/koalaman/shellcheck)
- [hadolint](https://github.com/hadolint/hadolint)

```sh
# Lint bash scripts
find . -type f \( -name '*.sh' \) | xargs shellcheck -x -s bash;

# Lint docker files
find . -type f \( -name '*.Dockerfile' \) | xargs hadolint;
```

## Back office access information

The default url/credentials to access to PrestaShop's back office defined in `./assets/hydrate.sh` and are set to:

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

## Q&A

## Does Flashlight support PrestaShop 1.6?

Partially yes. As there is no console whithin the sources, the modules cannot be automatically installed right now. Feel free to contribute!

## Api calls within a docker network

**Disclaimer**: PrestaShop is sensitive to the `Host` header of your client, and can behave surprisingly. In fact, since the Multi-shop feature is available, you cannot just call any front controller from any endpoint, unless... You set the ` Host` or the `id_shop` you are targeting.
**Disclaimer**: PrestaShop is sensitive to the `Host` header of your client, and can behave surprisingly. In fact, since the Multi-shop feature is available, you cannot just call any front controller from any endpoint, unless... You set the ` Host` or the `id_shop` you are targeting.

Let's explain this subtle - rather mandatory - knowledge:

Expand Down Expand Up @@ -196,7 +191,7 @@ server {
}
```

## Credits
# Credits

- https://github.com/PrestaShop/PrestaShop
- https://github.com/PrestaShop/performance-project
Expand Down