Skip to content

Commit 9f668f5

Browse files
- Updated docker documentation
- Minor clean up of unneeded docker configurations
1 parent cae9d15 commit 9f668f5

4 files changed

Lines changed: 34 additions & 31 deletions

File tree

docker-compose-testdb.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ services:
7474
working_dir: /app
7575
command: -V
7676
node:
77-
image: node:alpine
7877
build:
7978
context: ./docker/node
8079
volumes:

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ services:
5454
command: -V
5555

5656
node:
57-
image: node:alpine
5857
build:
5958
context: ./docker/node
6059
volumes:

docker/README.md

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
11
# Docker Development Environment
22

3+
>This is also documented at [UserFrosting Learn](https://learn.userfrosting.com/installation/environment/docker).
4+
35
First, install [Docker Compose](https://docs.docker.com/compose/install/).
46

57
Second, initialize a new UserFrosting project:
6-
1. Clone the repository `git clone https://github.com/userfrosting/UserFrosting.git .` and change into that directory `cd userfrosting`
7-
1. Run `cp app/sprinkles.example.json app/sprinkles.json` or upload your own (also upload your sprinkles if you have some)
8-
2. Run `sudo chown -R 33 app/{logs,cache,sessions}` (Changes the user to the www-data user of the image, more information [here](https://serversforhackers.com/c/dckr-file-permissions) )
9-
2. Run `sudo docker-compose run composer install` to install all composer modules.
10-
3. Run `sudo docker-compose run node npm install` to install all npm modules.
8+
9+
1. Copy `app/sprinkles.example.json` to `app/sprinkles.json`
10+
2. Run `chmod 777 app/{logs,cache,sessions}` to fix file permissions for web server. (NOTE: File
11+
permissions should be properly secured in a production environment!)
12+
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
13+
4. Run `docker-compose run node npm install` to install all npm modules.
14+
5. Run `docker-compose run composer update --ignore-platform-reqs --no-scripts` to install remaining composer modules
1115

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

14-
$ sudo docker-compose up -d
18+
$ docker-compose up -d
19+
20+
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):
21+
22+
$ docker exec -it -u www-data userfrosting_php_1 bash -c 'php bakery migrate'
1523

16-
On the first run you need to init the database (Be sure to execute this in the same directory, `${PWD##*/}` is a statement to get your current working directorys name. Docker uses it to name your container):
24+
You also need to setup the first admin user (again, your container name may be different depending on the name of your root directory):
1725

18-
$ sudo docker exec -it -u www-data ${PWD##*/}_php_1 bash -c 'php bakery migrate'
19-
20-
You also need to setup the first admin user (again, `${PWD##*/}` is a statement to get your current working directorys name):
26+
$ docker exec -it -u www-data userfrosting_php_1 bash -c 'php bakery create-admin'
2127

22-
$ sudo docker exec -it -u www-data ${PWD##*/}_php_1 bash -c 'php bakery create-admin'
28+
Now visit `http://localhost:8591/` to see your UserFrosting homepage!
2329

24-
Now visit http://localhost:8570/ to see your UserFrosting homepage!
30+
**Paste these into a bash file and execute it!**
2531

26-
**This is not (yet) meant for production!!**
32+
```
33+
chmod 777 app/{logs,cache,sessions}
34+
docker-compose build --force-rm --no-cache
35+
docker-compose run composer install --ignore-platform-reqs --no-scripts
36+
docker-compose run node npm install
37+
docker-compose run composer update --ignore-platform-reqs --no-scripts
38+
docker-compose up -d
39+
echo -n "Enter Docker Container Name --> "
40+
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+
```
44+
45+
**This is not (yet) meant for production!**
2746

2847
You may be tempted to run with this in production but this setup has not been security-hardened. For example:
2948

30-
- Database is exposed on port 8571 so you can access MySQL using your favorite client at localhost:8571. However,
49+
- Database is exposed on port 8593 so you can access MySQL using your favorite client at localhost:8593. However,
3150
the way Docker exposes this actually bypasses common firewalls like `ufw` so this should not be exposed in production.
3251
- Database credentials are hard-coded so obviously not secure.
3352
- File permissions may be more open than necessary.
53+
- HTTPS not implemented fully
3454
- It just hasn't been thoroughly tested in the capacity of being a production system.
35-
36-
## Updating your code
37-
As you might guessed you will have to run
38-
39-
$ sudo docker exec -it -u www-data userfrosting_php_1 bash -c 'php bakery migrate'
40-
41-
again if you want to migrate tables.
42-
You can change `php bakery migrate` to other `bakery` commands as well.
43-
Be aware that the userfrosting container doesn't know about npm!
44-
Similary for composer:
45-
46-
$ sudo docker-compose run composer update
47-
48-
See the [Docker](https://docs.docker.com/engine) and [Docker-compose documentation](https://docs.docker.com/compose/) for more details.

docker/php/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ RUN apt-get update && apt-get install -y \
88
&& docker-php-ext-install -j$(nproc) gd \
99
&& docker-php-ext-install -j$(nproc) pdo pdo_mysql \
1010
&& docker-php-ext-install -j$(nproc) zip
11-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
1211
WORKDIR /app

0 commit comments

Comments
 (0)