-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add divider comment between generic and specific sections - Grab composer from official docker image rather than web - Use a more robust shell - Make apt-install footprint smaller - Use OpenSSL with paths rather than use WORKDIR - Make project path setable through env var for build purposes - Only install non-dev dependencies with composer. The develop shoudl consciencely install deve dependencies because of develop PHP version(s) used. - Use COPY rather than ADD as per best practices
- Loading branch information
Showing
1 changed file
with
46 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,51 @@ | ||
FROM php:7.3-apache | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
|
||
# ============================================================================== | ||
# Set up the machine | ||
# ------------------------------------------------------------------------------ | ||
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer | ||
|
||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
||
RUN export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
git \ | ||
libzip-dev \ | ||
zlib1g-dev | ||
WORKDIR /tls | ||
RUN openssl req -new -x509 -days 365 -nodes \ | ||
-out server.cert \ | ||
-keyout server.key \ | ||
-subj "/C=RO/ST=Bucharest/L=Bucharest/O=IT/CN=www.example.ro" | ||
RUN docker-php-ext-install mysqli pdo pdo_mysql zip mbstring bcmath | ||
RUN a2enmod rewrite | ||
RUN a2enmod ssl | ||
RUN a2enmod headers | ||
WORKDIR /install | ||
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" | ||
RUN php composer-setup.php | ||
RUN php -r "unlink('composer-setup.php');" | ||
ADD . /app | ||
WORKDIR /app | ||
RUN php /install/composer.phar require lcobucci/jwt:3.3.3 | ||
RUN php /install/composer.phar update | ||
RUN php /install/composer.phar install | ||
zlib1g-dev \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN mkdir /tls && openssl req -new -x509 -days 365 -nodes \ | ||
-out /tls/server.cert \ | ||
-keyout /tls/server.key \ | ||
-subj "/C=NL/ST=Overijssel/L=Enschede/O=PDS Interop/OU=IT/CN=pdsinterop.org" | ||
|
||
RUN docker-php-ext-install \ | ||
bcmath \ | ||
mbstring \ | ||
mysqli \ | ||
pdo \ | ||
pdo_mysql \ | ||
zip | ||
|
||
RUN a2enmod headers rewrite ssl | ||
|
||
COPY site.conf /etc/apache2/sites-enabled/site.conf | ||
RUN chown -R www-data:www-data /app | ||
|
||
WORKDIR /app | ||
|
||
EXPOSE 443 | ||
# ============================================================================== | ||
|
||
|
||
# ============================================================================== | ||
# Add the source code | ||
# ------------------------------------------------------------------------------ | ||
ARG PROJECT_PATH | ||
RUN : "${PROJECT_PATH:=$PWD}" | ||
|
||
COPY "${PROJECT_PATH}" /app/ | ||
|
||
RUN composer install --no-dev --prefer-dist | ||
RUN chown -R www-data:www-data /app | ||
# ============================================================================== |