Skip to content

Commit bdb05c6

Browse files
committed
feat(img): add nginx image
1 parent 6d1642c commit bdb05c6

4 files changed

Lines changed: 90 additions & 16 deletions

File tree

docker-compose.yml

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ services:
1515
container_name: ${COMPOSER_PROJECT_NAME}-portainer
1616
volumes:
1717
- portainer-data:/data
18-
- ${DOCKER_SOCKET}:/var/run/docker.sock
18+
- "${DOCKER_SOCKET}:/var/run/docker.sock"
1919
networks:
2020
net:
2121
aliases:
22-
- portainer.${DOMAIN}
22+
- "portainer.${DOMAIN}"
2323
ports:
24-
- ${HOST_NET_ADDR}:9000:9000/tcp
24+
- "${HOST_NET_ADDR}:9000:9000/tcp"
2525

2626
dns:
27-
build: ./images/dnsmasq
27+
build: ./img/dnsmasq
2828
image: "${COMPOSE_PROJECT_NAME}-dns"
2929
container_name: "${COMPOSE_PROJECT_NAME}-dns"
3030
networks:
@@ -37,45 +37,56 @@ services:
3737
cap_add:
3838
- NET_ADMIN
3939

40+
nginx:
41+
build: ./img/nginx
42+
image: "${COMPOSE_PROJECT_NAME}-nginx"
43+
container_name: "${COMPOSE_PROJECT_NAME}-nginx"
44+
networks:
45+
default:
46+
aliases:
47+
- "nginx.${DOMAIN}"
48+
ports:
49+
- "${HOST_NET_ADDR}:8081:8081/tcp"
50+
4051
mysql:
4152
image: mysql
42-
container_name: ${COMPOSER_PROJECT_NAME}-mysql
53+
container_name: "${COMPOSER_PROJECT_NAME}-mysql"
4354
networks:
4455
net:
4556
aliases:
46-
- mysql.${DOMAIN}
57+
- "mysql.${DOMAIN}"
4758
ports:
48-
- ${HOST_NET_ADDR}:3306:3306/tcp
59+
- "${HOST_NET_ADDR}:3306:3306/tcp"
4960
environment:
5061
MYSQL_ROOT_PASSWORD: root
5162
volumes:
52-
- ${MYSQL_DATA}:/var/lib/mysql
63+
- "${MYSQL_DATA}:/var/lib/mysql"
5364
- ./etc/mysql:/etc/mysql/conf.d
5465

5566
composer:
5667
image: composer
57-
container_name: ${COMPOSER_PROJECT_NAME}-composer
68+
container_name: "${COMPOSER_PROJECT_NAME}-composer"
5869
networks:
5970
- net
6071
volumes:
61-
- ${PROJECT_DIR}:/project
72+
- "${PROJECT_DIR}:/project"
6273
working_dir: /project
6374

6475
php-cli:
6576
build: ./img/php-cli
66-
image: ${COMPOSER_PROJECT_NAME}-php-cli
67-
container_name: ${COMPOSER_PROJECT_NAME}-php-cli
77+
image: "${COMPOSER_PROJECT_NAME}-php-cli"
78+
container_name: "${COMPOSER_PROJECT_NAME}-php-cli"
6879
networks:
6980
net:
7081
aliases:
71-
- www.${DOMAIN}
82+
- "www.${DOMAIN}"
7283
ports:
73-
- ${HOST_NET_ADDR}:80:80/tcp
84+
- "${HOST_NET_ADDR}:80:80/tcp"
7485
volumes:
75-
- ${PROJECT_DIR}:/project
86+
- "${PROJECT_DIR}:/project"
7687
- ./etc/php/php.ini:/usr/local/etc/php/php.ini:ro
7788
- ./etc/php/php.ini.local:/usr/local/etc/php/conf.d/99-php-local.ini
78-
command: -S 0.0.0.0:80 -t ${PUBLIC_DIR}
89+
command: "-S 0.0.0.0:80 -t ${PUBLIC_DIR}"
7990

8091
proxy:
8192
image: jwilder/nginx-proxy

img/nginx/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM nginx:stable-alpine
2+
3+
RUN mkdir /http
4+
COPY ./conf/nginx.conf /etc/nginx/nginx.conf

img/nginx/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## A Simple Directory Index for Nginx
2+
3+
### Examples
4+
5+
#### Single Directory
6+
7+
With `/Users` mounted as `http://localhost:8080`
8+
9+
```shell
10+
docker run -p 8080:80 -i \
11+
-v /Users/:/http/users \
12+
nginx
13+
```
14+
15+
#### Multiple Directories
16+
17+
With `/mnt/disk1` mounted as `http://localhost:8080/disk1`
18+
And `/mnt/disk2` mounted as `http://localhost:8080/disk2`
19+
20+
```shell
21+
docker run -p 8060:80 -i \
22+
-v /mnt/disk1:/http/disk1 \
23+
-v /mnt/disk2:/http/disk2 \
24+
nginx
25+
```

img/nginx/conf/nginx.conf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
user root;
2+
worker_processes 1;
3+
4+
error_log /var/log/nginx/error.log warn;
5+
pid /var/run/nginx.pid;
6+
7+
events {
8+
worker_connections 1024;
9+
}
10+
11+
http {
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
15+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16+
'$status $body_bytes_sent "$http_referer" '
17+
'"$http_user_agent" "$http_x_forwarded_for"';
18+
19+
access_log /var/log/nginx/access.log main;
20+
21+
sendfile on;
22+
gzip on;
23+
keepalive_timeout 65;
24+
25+
server {
26+
listen 8081 default_server;
27+
server_name _;
28+
29+
location / {
30+
root /http;
31+
autoindex on;
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)