Skip to content

Instantly share code, notes, and snippets.

@phroggyy
Created February 6, 2019 19:03
Show Gist options
  • Save phroggyy/eba9fd563aa8f40eaf53954f9067942a to your computer and use it in GitHub Desktop.
Save phroggyy/eba9fd563aa8f40eaf53954f9067942a to your computer and use it in GitHub Desktop.
version: '3.7'
services:
app:
container_name: myapp
build:
context: .
target: base
volumes:
- .:/app
nginx:
container_name: myapp-nginx
image: nginx
volumes:
- ./nginx.conf.template:/etc/nginx/nginx.conf.template:cached
environment:
- HOST=app
command: /bin/bash -c "envsubst '\$$HOST' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && exec nginx -g 'daemon off;'"
ports:
- 82:80
db:
container_name: myapp-db
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=notifications
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=notifications
ports:
- 3306:3306
artisan:
container_name: myapp-artisan
build:
context: .
target: base
volumes:
- .:/app
entrypoint: "php artisan"
redis:
container_name: myapp-redis
image: redis
FROM php:7.1.8-fpm as base
WORKDIR /app
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client zlib1g-dev \
&& docker-php-ext-install mcrypt pdo_mysql zip pcntl
ENV COMPOSER_HOME ./.composer
COPY --from=composer:1.7.2 /usr/bin/composer /usr/bin/composer
FROM base as deps
RUN apt-get install -y git zip
COPY composer.json /app/composer.json
COPY composer.lock /app/composer.lock
# ARG SSH_COMPOSER_KEY
# RUN mkdir /root/.ssh/
# RUN echo "${SSH_COMPOSER_KEY}" > /root/.ssh/id_rsa
# RUN chmod 0400 /root/.ssh/id_rsa
RUN composer install --no-dev --no-autoloader --no-scripts
FROM base as prod
COPY --from=deps /app/vendor /app/vendor
ADD . /app
RUN chown -R www-data:www-data /app
RUN find /app -type d -exec chmod 755 {} \;
RUN find /app -type f -exec chmod 644 {} \;
RUN chgrp -R www-data /app/storage /app/bootstrap/cache
RUN chmod -R ug+rwx /app/storage /app/bootstrap/cache
RUN composer dump-autoload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment