Introduction: Why This Guide?
Setting up Akeneo PIM, especially a specific version like CE 5, can be a complex task involving many dependencies: a web server, the correct PHP version and extensions, a database, and a search server. This guide is the result of significant trial-and-error to create a stable, reproducible setup using Docker. It's designed for developers who want a reliable local environment for development, testing, or even a small-scale production deployment.
Core Technologies Explained
- Akeneo CE: An open-source Product Information Management (PIM) system built on the powerful Symfony PHP framework. It helps you centralize and harmonize all your product information.
- Docker: A platform that packages applications and their dependencies into isolated containers. This eliminates the 'it works on my machine' problem and ensures a consistent environment everywhere.
- MySQL: A popular open-source relational database that will store all your product data, attributes, families, and categories. Our setup uses a remote MySQL instance, common in cloud environments.
- Elasticsearch: A powerful search engine that Akeneo uses to provide fast and flexible product searching and filtering capabilities within the PIM.
- Apache & PHP-FPM: Apache is our web server that listens for requests, while PHP-FPM (FastCGI Process Manager) is an advanced and highly efficient processor for PHP that executes the Akeneo application code.
Project File Structure
Before we begin, create a project folder and place all the configuration files inside it. Your structure should look like this:
/akeneo-ce-project/
├── Dockerfile
├── docker-compose.yml
├── akeneo-pim.local.conf
├── run.sh
├── sshd_config
├── get_composer.sh
├── env_template
docker-compose.yml Explained
This file orchestrates our Docker setup. It defines the 'pim' service, builds the image using our Dockerfile, maps ports, and injects our database credentials as environment variables. Note that we are mapping three ports: 8080 for the Akeneo UI, 2222 for SSH access, and 80 to show it is possible to also expose the standard http port.
version: '3.4'
services:
pim:
image: 'gfacrakeneosazne.azurecr.io/akeneo_ce5:1'
working_dir: '/'
ports:
- 8080:80
- 2222:2222
- 80:80
environment:
APP_DATABASE_HOST: 'gf-sqlsrv-akeneodb-s-azne.mysql.database.azure.com'
APP_DATABASE_PORT: 'null'
APP_DATABASE_NAME: 'akeneo_local'
APP_DATABASE_USER: 'akeneo_pim'
APP_DATABASE_PASSWORD: 'ghytPAQg'
The Dockerfile: Building the Akeneo Image
This is where the magic happens. The Dockerfile builds our image layer by layer, installing all necessary system dependencies, configuring servers, and finally installing Akeneo itself. I've added comments to explain each major step.
# Use Ubuntu as the base image
FROM ubuntu:latest
# Install basic dependencies and PHP 7.4 with all required extensions
RUN apt update
RUN apt install --assume-yes lsb-release apt-transport-https ca-certificates wget gnupg make git
RUN DEBIAN_FRONTEND=noninteractive apt install --assume-yes php7.4-cli php7.4-apcu php7.4-bcmath php7.4-curl php7.4-fpm php7.4-gd php7.4-intl php7.4-mysql php7.4-xml php7.4-zip php7.4-zip php7.4-mbstring php7.4-imagick php7.4-exif
# Install and configure Apache web server
RUN apt install --assume-yes apache2
RUN a2enmod rewrite proxy_fcgi
RUN service apache2 restart
COPY akeneo-pim.local.conf /etc/apache2/sites-available/
# Install Node.js and Yarn for frontend assets
RUN apt install --assume-yes nodejs
RUN apt install --assume-yes yarnpkg
# Install and configure Elasticsearch 7.x
RUN apt install --assume-yes apt-transport-https
RUN wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN echo \"deb https://artifacts.elastic.co/packages/7.x/apt stable main\" | tee -a /etc/apt/sources.list.d/elastic-7.x.list
RUN apt update && apt install --assume-yes elasticsearch
# Configure Elasticsearch for a single-node cluster, essential for development environments
RUN echo \"discovery.type: single-node\" >> /etc/elasticsearch/elasticsearch.yml
# Install Composer (PHP package manager)
COPY get_composer.sh .
RUN sh get_composer.sh
RUN cp composer.phar /usr/local/bin/composer
# Download and install Akeneo CE 5
RUN wget https://download.akeneo.com/pim-community-standard-v5.0-latest-icecat.tar.gz
RUN tar xvzf pim-community-standard-v5.0-latest-icecat.tar.gz
WORKDIR /pim-community-standard
# We temporarily copy the .env file to run the installation make command
COPY .env /pim-community-standard/.env.local
RUN NO_DOCKER=true make prod
RUN rm .env.local
RUN chmod -R 777 /pim-community-standard
# Finalize Apache configuration
RUN apache2ctl configtest
RUN a2ensite akeneo-pim.local
RUN a2dissite 000-default
# Set up hosts file for local domain mapping
CMD echo \"127.0.0.1 akeneo-pim.local\" >> /etc/hosts
# Install and configure SSH server for debugging access
RUN apt update
RUN apt install --assume-yes openssh-server \\
&& echo \"root:Docker!\" | chpasswd
COPY sshd_config /etc/ssh/
# Copy and prepare the startup script
COPY run.sh /
RUN chmod 777 /run.sh
# Copy the environment template for the startup script to use
COPY env_template /
# Define the container's entrypoint
ENTRYPOINT [\"bash\", \"/run.sh\"]
# Expose ports
EXPOSE 80 2222
The run.sh Startup Script
This script is the container's entrypoint. It performs crucial startup tasks in the correct order: it dynamically creates the .env file from the template and environment variables, starts all necessary services (SSH, Elasticsearch, PHP, Apache), and then, after a delay to ensure Elasticsearch is ready, it resets and rebuilds Akeneo's search indexes. This final step is vital for the PIM to function correctly on first boot.
#/bin/bash
echo \"Starting ssh\"
service ssh start
echo \"apply environment variables\"
cd /pim-community-standard
rm .env
cp /env_template .env
sed -i \"s/{APP_DATABASE_HOST}/$APP_DATABASE_HOST/g\" .env
sed -i \"s/{APP_DATABASE_PORT}/$APP_DATABASE_PORT/g\" .env
sed -i \"s/{APP_DATABASE_NAME}/$APP_DATABASE_NAME/g\" .env
sed -i \"s/{APP_DATABASE_USER}/$APP_DATABASE_USER/g\" .env
sed -i \"s/{APP_DATABASE_PASSWORD}/$APP_DATABASE_PASSWORD/g\" .env
sed -i \"s/{AKENEO_PIM_URL}/$AKENEO_PIM_URL/g\" .env
echo \"Starting elastic\"
service elasticsearch stop
killall java
service elasticsearch start
echo \"Starting php\"
service php7.4-fpm start
echo \"Starting apache\"
service apache2 start
echo \"Waiting 60 seconds for elastic to start\"
sleep 60
echo \"Resetting indexes\"
php bin/console akeneo:elasticsearch:reset-indexes
echo \"Reindexing\"
php bin/console pim:product:index --all
tail -f /dev/null
Installation Steps
- Start Docker: Ensure Docker Desktop is running on your machine.
- Navigate to Project Directory: Open your terminal and `cd` into the folder where you saved all the configuration files.
- Run Docker Compose: Execute the following command. The `-d` flag runs the container in detached mode (in the background).
docker-compose up -d --build
- Wait for Setup: The first run will take a significant amount of time as Docker needs to download the Ubuntu image and run all the installation steps in the Dockerfile. Subsequent runs will be much faster. You can monitor the progress by running `docker-compose logs -f`.
- Access Akeneo: Once the container is running, open your web browser and navigate to http://localhost:8080. You should see the Akeneo login screen. Default credentials are typically `admin` / `admin`.
- Debugging via SSH: If you need to inspect the container, you can SSH into it using the port we mapped. The password is 'Docker!'.
ssh root@localhost -p 2222