Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Some QoL changes for the build process #16

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ MYSQL_USER=contenta
MYSQL_PASSWORD=contenta
MYSQL_ALLOW_EMPTY_PASSWORD=yes
MYSQL_ROOT_PASSWORD=root

HOSTNAME=contenta.local
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for decoupled development, it's maybe good having localhost as the host so things like service workers and so on don't get blocked?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a really good idea, as long as its on a port I guess. We really don't want to clobber other localhost apps that might be running on the host.

HOSTIP=192.168.1.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the final goal would be to have a network set up instead of fixing an IP?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, that would likely be a better idea. I was just putting this in as I didn't want it in the docker-compose.yml. Again, the more generic, the better, I suppose.


HOST_MYSQL_PORT=3336
HOST_PHP_PORT=9009
HOST_HTTP_PORT=8888
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ports maybe good to have by default but why don't use the default ports?

I'm guessing adding a .env.defaults with all this would be better instead and add .env to the gitignore

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, the defaults would be a good idea to use as a common base, I put those in as I wanted to show an example of slightly modified ports. But I'm fine with whatever.

HOST_HTTPS_PORT=4443
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Getting started

The following instructions will build the master 8.x-1.x build of the ContentaCMS and run in your active shell
```
docker-compose build
docker-compose up
```

This set of instructions will build according to a particular branch or tag of the ContentaCMS and run your containers detached (great if you have another application that monitors active containers (i.e.: kitematic)
```
docker-compose build --build-arg CMS_VERSION=v1.477
docker-compose up -d
```

# First-time initialization

The container doesn't automatically run `drush site-install` because we want it to be possible to stop and start an existing container without rebuilding the site every time. Instead, you need to manually run this after starting the container the first time:
Expand All @@ -19,5 +26,27 @@ When it finishes successsfully, the command will output a one-time login URL.

Persistent state is stored in two docker volumes (named `data` and `www`). You can destroy and recreate the containers as much as you like and your site will be preserved until you also destroy these volumes.

# .env File

You'll note that you can manage to change up some of the core values for the default db build configuration as well as where the services will sit and what ports they use externally.


```
MYSQL_DATABASE=contenta
MYSQL_USER=contenta
MYSQL_PASSWORD=contenta
MYSQL_ALLOW_EMPTY_PASSWORD=yes
MYSQL_ROOT_PASSWORD=root

HOSTNAME=contenta.local
HOSTIP=10.0.0.0

HOST_MYSQL_PORT=3306
HOST_PHP_PORT=9000
HOST_HTTP_PORT=80
HOST_HTTPS_PORT=443
```

It's really important to manage these values according to where this solution will sit. Both in a secure and insecure environment.

If you have an environment where you've already used up the MySQL port 3306 for a service that is on your local machine, than change this to something else. You can use anything between 1-65535. Although, for the sake of simplicity and convenience, maybe using something like 3336 might be easier to remember. The same thing can be said of any of the other ports used by this project. Assigning new port numbers for your local setup will greatly diminish any conflicts and build and up command issues.
19 changes: 13 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ services:
nginx:
build: ./nginx
ports:
- "80:80"
- "443:443"
- "${HOST_HTTP_PORT}:80"
#- "80:80"
- "${HOST_HTTPS_PORT}:443"
#- "443:443"
# extra_hosts:
# - "${HOSTNAME}:${HOSTIP}"
networks:
- contenta
volumes:
Expand All @@ -16,7 +20,8 @@ services:
php:
build: ./php
ports:
- "9000:9000"
- "${HOST_PHP_PORT}:9000"
#- "9000:9000"
volumes:
- www:/var/www
env_file:
Expand All @@ -26,17 +31,19 @@ services:
database:
build: ./database
ports:
- "3306:3306"
# HOST:CONTAINER
- "${HOST_MYSQL_PORT}:3306"
#- "3306:3306"
volumes:
- data:/var/lib/mysql
env_file:
- .env
networks:
networks:
- contenta

volumes:
data:
www:

networks:
contenta:
contenta:
3 changes: 2 additions & 1 deletion php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ RUN mkdir -p /var/www && \
chmod +x /usr/local/bin/docker-entrypoint && \
chmod +x /usr/local/bin/init-drupal

ARG CMS_VERSION=8.x-1.x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONTENTA_VERSION?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, that's the contenta_version. Obviously, the base here. I added the CMS_VERSION as this is how it was identified somewhere in the contenta build. So, just took a cue off them.

RUN cd /usr/local/src && \
git clone https://github.com/contentacms/contenta_jsonapi && \
git clone https://github.com/contentacms/contenta_jsonapi --branch ${CMS_VERSION} && \
cd /usr/local/src/contenta_jsonapi && \
composer create-project contentacms/contenta-jsonapi-project /var/www --stability dev --no-interaction && \
cd /var/www && \
Expand Down
2 changes: 2 additions & 0 deletions php/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ ep /etc/php.ini
ep /etc/php-fpm.conf
ep /etc/php-fpm.d/*

[ ! -e /run/php-fpm ] && mkdir -p /run/php-fpm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed in one of the forks, this was a problem for some, where the fpm workers weren't starting due to a missing path. I put it in just as a precaution. I've also noticed this setup in docker4drupal, so it must be a common fix.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this solves the issue i run into, where its missing that folder and errors out thus php container never runs, seems like this issue was reported here: #17

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


exec "$@"