|
| 1 | +FROM alpine:3.3 |
| 2 | + |
| 3 | +# Expose HTTP HTTPS and Caddy ports |
| 4 | +EXPOSE 80 443 2015 |
| 5 | + |
| 6 | +# Update/Upgrade packages |
| 7 | +RUN apk update --no-cache && apk upgrade --no-cache --available |
| 8 | + |
| 9 | +# Install ssh-client, php and required php extensions for composer and app |
| 10 | +RUN apk add --no-cache --update \ |
| 11 | + openssh-client \ |
| 12 | + tar \ |
| 13 | + php \ |
| 14 | + php-curl \ |
| 15 | + php-openssl \ |
| 16 | + php-phar \ |
| 17 | + php-pcntl \ |
| 18 | + php-json |
| 19 | + |
| 20 | +# Register the COMPOSER_HOME environment variable |
| 21 | +ENV COMPOSER_HOME /composer |
| 22 | + |
| 23 | +# Add global binary directory to PATH and make sure to re-export it |
| 24 | +ENV PATH /composer/vendor/bin:$PATH |
| 25 | + |
| 26 | +# Allow Composer to be run as root |
| 27 | +ENV COMPOSER_ALLOW_SUPERUSER 1 |
| 28 | + |
| 29 | +# Setup the Composer installer |
| 30 | +RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer \ |
| 31 | + && curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig \ |
| 32 | + && php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" |
| 33 | + |
| 34 | +# Install composer and show version information |
| 35 | +RUN php /tmp/composer-setup.php --install-dir=/usr/sbin --filename=composer \ |
| 36 | + && rm -rf /tmp/composer-setup.php \ |
| 37 | + && composer --version |
| 38 | + |
| 39 | +# Download and install Caddy and show version information |
| 40 | +RUN curl --silent --show-error --fail --location \ |
| 41 | + --header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \ |
| 42 | + "https://caddyserver.com/download/build?os=linux&arch=amd64" \ |
| 43 | + | tar --no-same-owner -C /usr/sbin/ -xz caddy \ |
| 44 | + && chmod 0755 /usr/sbin/caddy \ |
| 45 | + && /usr/sbin/caddy -version |
| 46 | + |
| 47 | +# Set the working directory to /srv |
| 48 | +WORKDIR /srv |
| 49 | + |
| 50 | +# Copy application to container |
| 51 | +COPY app/ /srv |
| 52 | + |
| 53 | +# Run composer on application |
| 54 | +RUN chdir /srv && /usr/sbin/composer --ansi install |
| 55 | + |
| 56 | +# Copy Caddy config file over |
| 57 | +ADD Caddyfile /etc/Caddyfile |
| 58 | + |
| 59 | +# Set container entry point and parameters to Caddy |
| 60 | +ENTRYPOINT ["/usr/sbin/caddy"] |
| 61 | +CMD ["--conf", "/etc/Caddyfile"] |
0 commit comments