Sign inSign up

remuslazar/docker-neos-alpine

By remuslazar

•Updated over 7 years ago

Fork of psmb/docker-neos-alpine with some tweaks (WIP)

Image
0

3.9K

remuslazar/docker-neos-alpine repository overview

⁠dimaip/docker-neos-apline⁠ ·

Image info⁠

Opinionated Neos CMS⁠ docker image based on Alpine linux with nginx + php-fpm 7.2 + s6 process manager, packing everything needed for development and production usage of Neos in under 100mb.

The image does a few things:

  1. Automatically install and provision a Neos website, based on environment vars documented below
  2. Pack a few useful things like XDEBUG integration, git, beard etc.
  3. Be ready to be used in production and serve as a rolling deployment target with this Ansible script https://github.com/psmb/ansible-deploy⁠ (I gave up on this deployment method, use 2.x version of this image if you need it, but rather consider full conatiner deployment)

Check out this shell script⁠ to see what exactly this image can do for you.

⁠Usage

This image supports following environment variable for automatically configuring Neos at container startup:

Docker env variableDescription
WWW_PORTTCP port on which the container will serve incoming HTTP requests, defaults to 80.
REPOSITORY_URLLink to Neos website distribution
SITE_INIT_SCRIPTIf set, a path (relative to SITE_PACKAGE folder) to a bash script which will be called (synchronously) after the container is ready but prior to nginx. Note that this script will be executed as user www-data (and not root!)
SETUP_BEHATIf set to true, the init process will call flow behat:setup and also do a cache:warmup for the Development/Behat context. Default it false.
VERSIONGit repository branch, commit SHA or release tag, defaults to master
SITE_PACKAGENeos website package with exported website data to be imported, optional
ADMIN_PASSWORDIf set, would create a Neos admin user with such password, optional
BASE_URI2.x image only. If set, set the baseUri option in Settings.yaml, optional
DONT_PUBLISH_PERSISTENTDon't publish persistent assets on init. Needed e.g. for cloud resources.
AWS_BACKUP_ARNAutomatically import the database from ${AWS_RESOURCES_ARN}db.sql on the first container launch. Requires AWS_ACCESS_KEY, AWS_SECRET_ACCESS_KEY and AWS_ENDPOINT (optional, for S3-compatible storage) to be set in order to work.
COMPOSER_INSTALL_PARAMScomposer install parameters, defaults to --prefer-source
DB_AUTO_BACKUPAutomatically backup database at given interval, possible values: 15min, hourly, daily, weekly, monthly. If AWS_BACKUP_ARN configured, would also upload the file at ${AWS_RESOURCES_ARN}db.sql location.
XDEBUG_CONFIGPass xdebug config string, e.g. idekey=PHPSTORM remote_enable=1. If no config provided the Xdebug extension will be disabled (safe for production), off by default
IMPORT_GITHUB_PUB_KEYSWill pull authorized keys allowed to connect to this image from your Github account(s).
DB_DATABASEDatabase name, defaults to db
DB_HOSTDatabase host, defaults to db
DB_PASSDatabase password, defaults to pass
DB_USERDatabase user, defaults to admin
AWS_PROFILEaws profile to use when configuring the aws cli
AWS_REGIONaws region
AWS_ACCESS_KEY_IDaws access key
AWS_SECRET_ACCESS_KEYaws secret key

In addition to these settings, if you place database sql dump at Data/Persistent/db.sql, it would automatically be imported on the first container launch. See above for options to automatically download the data from AWS S3. If beard.json file is present, your distribution will get bearded⁠.

The container has the crond daemon running, put your scripts to /etc/periodic or crontab -e.

Example docker-compose.yml configuration:

web:
  image: remuslazar/docker-neos-alpine:latest
  ports:
    - '8080:8080'
    - '1122:22'
  links:
    - db:db
  volumes:
    - data:/data
    # needed only for initial provisioning, if REPOSITORY_URL not set
    # - .:/src/
  environment:
    WWW_PORT: 8080
#    AWS_REGION: eu-central-1
#    AWS_ACCESS_KEY_ID: ...
#    AWS_SECRET_ACCESS_KEY: ...
    REPOSITORY_URL: 'https://github.com/neos/neos-development-distribution'
    SITE_PACKAGE: 'Neos.Demo'
    VERSION: '3.3'
    ADMIN_PASSWORD: 'password'
    IMPORT_GITHUB_PUB_KEYS: 'your-github-user-name'
    AWS_RESOURCES_ARN: 's3://some-bucket/sites/demo/'
    COMPOSER_INSTALL_PARAMS: '--no-dev'
db:
  image: mariadb:latest
  expose:
    - 3306
  volumes:
    - /var/lib/data
  environment:
    MYSQL_DATABASE: 'db'
    MYSQL_USER: 'admin'
    MYSQL_PASSWORD: 'pass'
    MYSQL_RANDOM_ROOT_PASSWORD: 'yes'

volumes:
  data:

⁠Provisioning Process

For initial privisioning the container, you can use the REPOSITORY_URL ENV var. If so, the initialization logic will perform a git clone.

Another alternative is to use a Docker mount or volume. Mount the source dir to /src and make sure not to set the REPOSITORY_URL. Then the init logic will just rsync -a from /src to /data/www-provisioned instead.

⁠Flow/Neos Context

FLOW_CONTEXT will be set to Production by default. For development use a host name with a dev subdomain, like dev.mysite.local, this will use the Development context instead.

⁠Utility scripts

Also this container provides a couple of utility scripts, they are located in the /data folder.

Script nameDescription
backupDb.shDumps database into /data/www/Data/Persistent/db.sql and uploads it to AWS S3, if it is set up.
syncDb.shImports /data/www/Data/Persistent/db.sql, and dowloads it from AWS S3 beforehand, if it is set up.
syncCode.shFor development purpose only! pulls latest code from git, does composer install and a few other things, see code.
syncAll.shRuns both syncDb and syncCode

⁠Backups

Each container automatically takes care of daily backing up itself by running the /data/backupDb.sh script, which dumps DB and optionally uploads it to AWS S3. So if you store persistent resources on AWS S3, you are good to go (you should probably additionally backup the contents of S3 to some offline storage, but that's a different story).

⁠Two-step provisioning

You may build pre-provisioned images dedicated for your project from such Dockerfile:

FROM dimaip/docker-neos-alpine:latest
ENV PHP_TIMEZONE=Europe/Moscow
ENV REPOSITORY_URL=https://github.com/sfi-ru/ErmDistr
RUN /provision-neos.sh

It will already pre-install your project by running composer install, so the remaining startup will take about 10s, instead of minutes.

Tag summary

Content type

Image

Digest

Size

101.7 MB

Last updated

about 8 years ago

docker pull remuslazar/docker-neos-alpine