Skip to content

Commit d4b087b

Browse files
committed
removed capability of setting hostname on run time.
added APP_HOSTNAME build argument to set hostname during build time
1 parent 56e388f commit d4b087b

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ or better yet, at:
3838
- myapp.local/phpinfo.php
3939
- myapp.local/adminer.php
4040

41-
**If you wish to change the hostname from myapp.local to something else, you can do**
41+
To build with your a different hostname.local address, do this:
4242

4343
```
44-
APP_URL=something.local docker-compose up -d
44+
docker-compose build --build-arg HOST_UID=$(id -u) --build-arg APP_HOSTNAME=your_hostname
4545
```
4646

4747
## File Paths
@@ -77,10 +77,11 @@ Example 2: to set a specific UID `--build-arg HOST_UID=1001`
7777

7878
Web Servers:
7979
- `WEB`=**httpd** | nginx
80+
- `APP_HOSTNAME`=**myapp** | _string_
8081

8182
Database Management System:
8283
- `DB`=**mariadb** | mysql
83-
- `DB_VERSION`=**latest** | num
84+
- `DB_VERSION`=**latest** | _num_
8485

8586
PHP
8687
- `PHP_VERSION`=**7** | 7.4 | 7.3 | 7.2 | 7.1 | 7.0 | 5.6

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ services:
88
volumes:
99
- ./app/web/:/var/www/html/
1010
web_server:
11-
hostname: ${APP_URL:-myapp.local}
1211
build:
1312
context: './docker/web/'
1413
depends_on:

docker/web/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ FROM $WEB:latest
44
RUN apt-get update -y
55
RUN apt-get install -y --no-install-recommends avahi-daemon libnss-mdns
66

7+
ARG APP_HOSTNAME="myapp.local"
8+
RUN echo $APP_HOSTNAME | sed 's/.local//g' > /etc/app_hostname
9+
710
# Copy apache config
811
COPY httpd/vhost.conf /usr/local/apache2/conf/vhost.conf
912
RUN echo "Include /usr/local/apache2/conf/vhost.conf" \
@@ -13,7 +16,8 @@ RUN echo "Include /usr/local/apache2/conf/vhost.conf" \
1316
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
1417

1518
# setup avahi
16-
RUN printf "[server]\nenable-dbus=no\n" >> /etc/avahi/avahi-daemon.conf
19+
RUN printf "[server]\nenable-dbus=no\nhost-name=$(cat /etc/app_hostname)\n" >> /etc/avahi/avahi-daemon.conf
1720

1821
# run avahi and the web server
19-
CMD avahi-daemon --daemonize --no-drop-root; httpd -DFOREGROUND || nginx -g "daemon off;"
22+
CMD avahi-daemon --daemonize --no-drop-root; \
23+
httpd -DFOREGROUND || nginx -g "daemon off;"

0 commit comments

Comments
 (0)