Skip to content

Commit 33daa22

Browse files
committed
h2 and HTTPS support
1 parent 313bda6 commit 33daa22

File tree

4 files changed

+65
-14
lines changed

4 files changed

+65
-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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM alpine:latest
2+
3+
RUN apk add --no-cache 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+
RUN openssl rsa -passin pass:NotSecure -in server.pass.key -out server.key
8+
RUN rm server.pass.key
9+
RUN openssl req -new -passout pass:NotSecure -key server.key -out server.csr \
10+
-subj '/C=SS/ST=SS/L=Gotham City/O=Symfony/CN=localhost'
11+
RUN openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
12+
13+
FROM httpd:2.4-alpine
14+
15+
COPY --from=0 server.key /usr/local/apache2/conf/server.key
16+
COPY --from=0 server.crt /usr/local/apache2/conf/server.crt
17+
COPY ./docker/httpd/httpd.conf /usr/local/apache2/conf/httpd.conf

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

Lines changed: 10 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,13 @@ 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+
- ./docker/httpd/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro
34+
ports:
35+
- '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)