Skip to content

Commit 0097dba

Browse files
committed
h2 and HTTPS support
1 parent 313bda6 commit 0097dba

File tree

4 files changed

+74
-14
lines changed

4 files changed

+74
-14
lines changed

Dockerfile

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,25 @@ RUN set -xe \
3737
# https://getcomposer.org/doc/03-cli.md#composer-allow-superuser
3838
ENV COMPOSER_ALLOW_SUPERUSER 1
3939

40-
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative \
41-
&& composer clear-cache
40+
# Use prestissimo to speed up builds
41+
RUN composer global require "hirak/prestissimo:^0.3" --prefer-dist --no-progress --no-suggest --optimize-autoloader --classmap-authoritative
42+
43+
COPY docker/app/docker-entrypoint.sh /usr/local/bin/docker-app-entrypoint
44+
RUN chmod +x /usr/local/bin/docker-app-entrypoint
45+
46+
# Download the Symfony skeleton and leverage Docker cache layers
47+
ENV SKELETON_COMPOSER_JSON https://raw.githubusercontent.com/symfony/skeleton/v3.3.4/composer.json
4248

4349
WORKDIR /srv/app
50+
RUN php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');" \
51+
&& composer install --prefer-dist --no-dev --no-progress --no-suggest --no-autoloader --no-scripts --no-plugins --no-interaction
4452

4553
COPY . .
46-
# Cleanup unneeded files
47-
RUN rm -Rf docker/
48-
49-
# Download the Symfony skeleton
50-
ENV SKELETON_COMPOSER_JSON https://raw.githubusercontent.com/symfony/skeleton/v3.3.2/composer.json
51-
RUN [ -f composer.json ] || php -r "copy('$SKELETON_COMPOSER_JSON', 'composer.json');"
5254

5355
RUN mkdir -p var/cache var/logs var/sessions \
5456
&& composer install --prefer-dist --no-dev --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --no-interaction \
5557
&& composer clear-cache \
56-
# Permissions hack because setfacl does not work on Mac and Windows
57-
&& chown -R www-data var
58-
59-
COPY docker/app/docker-entrypoint.sh /usr/local/bin/docker-app-entrypoint
60-
RUN chmod +x /usr/local/bin/docker-app-entrypoint
58+
&& chown -R www-data var # Permissions hack because setfacl does not work on Mac and Windows
6159

6260
ENTRYPOINT ["docker-app-entrypoint"]
6361
CMD ["php-fpm"]

Dockerfile.h2-proxy

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM httpd:2.4-alpine
2+
3+
RUN apk add --no-cache --virtual .persistent-deps openssl
4+
5+
# Use this self-generated certificate only in dev, IT IS NOT SECURE!
6+
RUN openssl genrsa -des3 -passout pass:NotSecure -out server.pass.key 2048 \
7+
&& openssl rsa \
8+
-passin pass:NotSecure \
9+
-in server.pass.key \
10+
-out /usr/local/apache2/conf/server.key \
11+
&& rm server.pass.key \
12+
&& openssl req \
13+
-new \
14+
-passout pass:NotSecure \
15+
-subj '/C=SS/ST=SS/L=Gotham City/O=Symfony/CN=localhost' \
16+
-key /usr/local/apache2/conf/server.key \
17+
-out /usr/local/apache2/conf/server.csr \
18+
&& openssl x509 \
19+
-req -sha256 \
20+
-days 365 \
21+
-in /usr/local/apache2/conf/server.csr \
22+
-signkey /usr/local/apache2/conf/server.key \
23+
-out /usr/local/apache2/conf/server.crt
24+
25+
COPY ./docker/httpd/httpd.conf /usr/local/apache2/conf/httpd.conf

docker-compose.yml renamed to docker-compose.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ services:
1212
- /srv/app/var/cache/
1313
- /srv/app/var/logs/
1414
- /srv/app/var/sessions/
15-
- /srv/app/vendor/
1615

1716
nginx:
1817
build:
@@ -24,3 +23,14 @@ services:
2423
- ./public:/srv/app/public:ro
2524
ports:
2625
- '80:80'
26+
27+
# This HTTP/2 proxy is not secure: it should only be used in dev
28+
h2-proxy:
29+
build:
30+
context: .
31+
dockerfile: ./Dockerfile.h2-proxy
32+
volumes:
33+
# Comment out the next line in production
34+
- ./docker/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro
35+
ports:
36+
- '443:443'

docker/httpd/httpd.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ServerName localhost
2+
Listen 443
3+
4+
SSLEngine on
5+
SSLCertificateFile "/usr/local/apache2/conf/server.crt"
6+
SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
7+
SSLSessionCache "shmcb:/usr/local/apache2/logs/ssl_scache(512000)"
8+
9+
User daemon
10+
Group daemon
11+
12+
ErrorLog /proc/self/fd/2
13+
CustomLog /proc/self/fd/1 "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
14+
15+
Protocols h2 http/1.1
16+
17+
ProxyPass / http://nginx/
18+
ProxyPassReverse / http://nginx/
19+
20+
LoadModule authz_core_module modules/mod_authz_core.so
21+
LoadModule http2_module modules/mod_http2.so
22+
LoadModule log_config_module modules/mod_log_config.so
23+
LoadModule proxy_module modules/mod_proxy.so
24+
LoadModule proxy_http_module modules/mod_proxy_http.so
25+
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
26+
LoadModule ssl_module modules/mod_ssl.so
27+
LoadModule unixd_module modules/mod_unixd.so

0 commit comments

Comments
 (0)