Skip to content

Commit d4157ce

Browse files
Updated docker configuration
- Use Alpine for PHP - Removed commands from composer and node services in favour of on-demand command execution - Updated docker README
1 parent 55dd433 commit d4157ce

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,13 @@ services:
5151
volumes:
5252
- .:/app
5353
working_dir: /app
54-
command: -V
5554

5655
node:
5756
build:
5857
context: ./docker/node
5958
volumes:
6059
- .:/app
6160
working_dir: /app/build
62-
command: npm run uf-assets-install
6361

6462
volumes:
6563
userfrosting-db:

docker/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ Second, initialize a new UserFrosting project:
1212
3. Run `docker-compose run composer install --ignore-platform-reqs --no-scripts` to install all composer modules. (https://hub.docker.com/_/composer) Sometimes dependencies or Composer scripts require the availability of certain PHP extensions. You can work around this as follows: Pass the `--ignore-platform-reqs and --no-scripts` flags to install or update
1313
4. Run `docker-compose run node npm install` to install all npm modules.
1414
5. Run `docker-compose run composer update --ignore-platform-reqs --no-scripts` to install remaining composer modules
15+
6. Run `docker-compose run node npm run uf-assets-install` to install all frontend vendor assets.
1516

1617
Now you can start up the entire Nginx + PHP + MySQL stack using docker with:
1718

1819
$ docker-compose up -d
1920

2021
the `-d` flag will launch this in the background so you can continue to use the terminal window. On the first run you need to init the database (your container name may be different depending on the name of your root directory):
2122

22-
$ docker exec -it -u www-data userfrosting_php_1 bash -c 'php bakery migrate'
23+
$ docker exec -it -u www-data userfrosting_php_1 sh -c 'php bakery migrate'
2324

2425
You also need to setup the first admin user (again, your container name may be different depending on the name of your root directory):
2526

26-
$ docker exec -it -u www-data userfrosting_php_1 bash -c 'php bakery create-admin'
27+
$ docker exec -it -u www-data userfrosting_php_1 sh -c 'php bakery create-admin'
2728

2829
Now visit `http://localhost:8591/` to see your UserFrosting homepage!
2930

@@ -35,11 +36,12 @@ docker-compose build --force-rm --no-cache
3536
docker-compose run composer install --ignore-platform-reqs --no-scripts
3637
docker-compose run node npm install
3738
docker-compose run composer update --ignore-platform-reqs --no-scripts
39+
docker-compose run node npm run uf-assets-install
3840
docker-compose up -d
3941
echo -n "Enter Docker Container Name --> "
4042
read docker_container
41-
docker exec -it -u www-data $docker_container bash -c 'php bakery migrate'
42-
docker exec -it -u www-data $docker_container bash -c 'php bakery create-admin'
43+
docker exec -it -u www-data $docker_container sh -c 'php bakery migrate'
44+
docker exec -it -u www-data $docker_container sh -c 'php bakery create-admin'
4345
```
4446

4547
**This is not (yet) meant for production!**

docker/php/Dockerfile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
FROM php:7.2-fpm
2-
RUN apt-get update && apt-get install -y \
3-
libfreetype6-dev \
4-
libjpeg62-turbo-dev \
1+
FROM php:7.2-fpm-alpine
2+
3+
# Update and install packages
4+
RUN apk update
5+
RUN apk add \
6+
freetype-dev \
7+
libjpeg-turbo-dev \
58
libpng-dev \
6-
zip \
7-
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
9+
zip
10+
11+
# Install and configure PHP extensions
12+
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
813
&& docker-php-ext-install -j$(nproc) gd \
914
&& docker-php-ext-install -j$(nproc) pdo pdo_mysql \
1015
&& docker-php-ext-install -j$(nproc) zip
16+
1117
WORKDIR /app

0 commit comments

Comments
 (0)