Skip to content

Commit

Permalink
Update How to use to explain how to build and run the dockers locally
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Nov 7, 2024
1 parent 1247134 commit 0f998da
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ jobs:
run: ./generate_tags.sh
working-directory: base

- name: Base Images > Docker Build Tags
- name: Base Images > Docker Build Tags without pushing
run: ./docker_tags.sh
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name != 'push' || github.ref != 'refs/heads/master' || steps.changes.outputs.base != 'true' }}
working-directory: base

- name: Base Images > Docker Build & Push
- name: Base Images > Docker Build & Force Push
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.changes.outputs.base == 'true' }}
run: ./docker_tags.sh -p -f
working-directory: base
Expand Down
43 changes: 43 additions & 0 deletions HOW-TO-USE.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,46 @@ $ nosetests --with-id 7
```
This will also generate a `.nodeids` binary file, when you add new test methods you need to remove this file to re-generate the list of IDs.
## Building and running PrestaShop docker locally
First to make sure you will use the local docker containers and not the ones from Docker hub make sure you remove all existing PrestaShop images (including the base images)
```
# This should be empty to be extra sure
$ docker images
```
Then you'll have to build the base image for the PHP version and server you are willing to use. If you are on MacOS this is crucial that you clean any image from cache and tun this locally,
especially if your architecture is based on linux/arm64 (processor M1, M2, ...).
```shell
docker build base/images/8.3-apache -t prestashop/base:8.3-apache
# You should see an image with Repository: prestashop Tag: 8.3-apache
docker images
```
Then you can build the image of the PrestaShop version you want to use:
```
# Now build the PrestaShop version you want based on this local base image
$ docker build images/9.0.x/8.3-apache -t prestashop/prestashop:9.0.x-8.3-apache
```
Finally, you can launch your PrestaShop container using docker compose
```
$ PS_VERSION=9.0.x PHP_VERSION=8.3 docker compose -f images/docker-compose.yml up
```
Or you can use this script that performs these actions based on the arguments
```
# Default values are nightly 8.3 apache
./build-local-docker.sh 9.0.x 8.1 fpm
```
Now you should be able to access a shop at this address: `http://localhost:8001/`
The BO is accessible at `http://localhost:8001/admin-dev` with the following login:
Email: `[email protected]`
Password: `Correct Horse Battery Staple`
26 changes: 26 additions & 0 deletions build-local-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

PS_VERSION=nigthly
PHP_VERSION=8.3
SERVER=apache

if [ $# -gt 0 ]; then
PS_VERSION=$1
fi
if [ $# -gt 1 ]; then
PHP_VERSION=$2
fi
if [ $# -gt 2 ]; then
SERVER=$3
fi

echo Building PrestaShop $PS_VERSION with PHP $PHP_VERSION and Server $SERVER

echo Building base image for PHP $PHP_VERSION with $SERVER
docker build base/images/$PHP_VERSION-$SERVER -t prestashop/base:$PHP_VERSION-$SERVER

echo Building PrestaShop image for version $PS_VERSION
docker build images/$PS_VERSION/$PHP_VERSION-$SERVER -t prestashop/prestashop:$PS_VERSION-$PHP_VERSION-$SERVER

echo Launching docker container with docker compose
PS_VERSION=$PS_VERSION PHP_VERSION=$PHP_VERSION SERVER=$SERVER docker compose -f images/docker-compose.yml up
47 changes: 47 additions & 0 deletions images/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '2.1'

services:
mysql:
image: mysql:8
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWD:-prestashop}
MYSQL_DATABASE: ${DB_NAME:-prestashop}
restart: unless-stopped
networks:
- prestashop-network

prestashop:
image: prestashop/prestashop:${PS_VERSION}-${PHP_VERSION}-${SERVER:-apache}
container_name: prestashop
depends_on:
- mysql
environment:
DISABLE_MAKE: ${DISABLE_MAKE:-0}
PS_INSTALL_AUTO: ${PS_INSTALL_AUTO:-1}
DB_PASSWD: ${DB_PASSWD:-prestashop}
DB_NAME: ${DB_NAME:-prestashop}
DB_SERVER: ${DB_SERVER:-mysql}
DB_PREFIX: ${DB_PREFIX:-ps_}
PS_DOMAIN: ${PS_DOMAIN:-localhost:8001}
PS_FOLDER_INSTALL: ${PS_FOLDER_INSTALL:-install-dev}
PS_FOLDER_ADMIN: ${PS_FOLDER_ADMIN:-admin-dev}
PS_COUNTRY: ${PS_COUNTRY:-fr}
PS_LANGUAGE: ${PS_LANGUAGE:-en}
PS_DEV_MODE: ${PS_DEV_MODE:-1}
PS_ENABLE_SSL: ${PS_ENABLE_SSL:-0}
PS_ERASE_DB: ${PS_ERASE_DB:-0}
PS_USE_DOCKER_MAILDEV: ${PS_USE_DOCKER_MAILDEV:-1}
ADMIN_MAIL: ${ADMIN_MAIL:[email protected]}
ADMIN_PASSWD: ${ADMIN_PASSWD:-Correct Horse Battery Staple}
NODE_VERSION: ${NODE_VERSION:-v20.17.0}
ports:
- "8001:80"
- "8002:443"
networks:
- prestashop-network

networks:
prestashop-network:
name: prestashop-network

0 comments on commit 0f998da

Please sign in to comment.