├── .gitignore ├── README.md ├── bin ├── install-project.sh └── publish_chart.sh ├── chart ├── .helmignore ├── Chart.yaml ├── templates │ ├── NOTES.txt │ ├── _helpers.tpl │ ├── configMap.yaml │ ├── db-secrets.yaml │ ├── deployment.yaml │ ├── ingress.yaml │ └── service.yaml └── values.yaml ├── docker-compose.yml ├── docker ├── Dockerfile.nginx ├── Dockerfile.phpfpm ├── conf │ ├── laravel.conf │ ├── nginx.conf │ ├── php.ini │ └── xdebug.ini ├── db │ └── .keep └── laravel │ └── .keep └── laravel-homepage.png /.gitignore: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # 3 | # Git Ignore Config, https://git-scm.com/docs/gitignore. 4 | # 5 | #------------------------------------------------------------------------------- 6 | 7 | # Laravel project 8 | docker/laravel 9 | 10 | # Container data 11 | docker/logs 12 | docker/db/dbdata 13 | 14 | # Editor files 15 | /.idea 16 | /.vscode 17 | /nbproject 18 | 19 | # Hidden and data files 20 | *.DS_Store 21 | *Thumbs.db 22 | *.bak 23 | *.swp -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deploy laravel on Kubernetes with Helm chart 2 | 3 | To more easily deploy and manage the Laravel application containers in a Kubernetes cluster, you can use Helm charts. 4 | 5 | This guide walks you through the process of running an laravel application on a Kubernetes cluster. I will use PHP-FPM (FastCGI Process Manager), Nginx and MariaDB to run the application. 6 | 7 | ## How to get started? 8 | 9 | Before you begin, please ensure [Docker](https://www.docker.com/), [Docker Compose](https://docs.docker.com/compose/), [Helm](https://helm.sh/) and [Kubernetes](https://github.com/dambergautam/docker-examples/blob/master/4-kubernetes/kubernetes-setup.md) are installed and Docker is running. 10 | 11 | **Step 1:** 12 | 13 | Clone this project `git clone https://github.com/dambergautam/laravel-kubernetes-helm.git`. 14 | 15 | **Step 2:** 16 | 17 | Run below command to add blank laravel project from root directory. 18 | 19 | ``` 20 | bash ./bin/install-project.sh 21 | ``` 22 | 23 | This command will 24 | - install new laravel project `docker/laravel` 25 | - create docker images and run containers 26 | - perform series of Laravel Artisan and NPM commands in the container. 27 | 28 | To access website locally, visit http://localhost:82/. 29 | 30 | ![Homepage Screenshot](./laravel-homepage.png) 31 | 32 | **Step 3:** 33 | 34 | To deploy the application on kubernetes using helm chart, create PHPFPM image 35 | with laravel application source 36 | 37 | ``` 38 | # Create new image 39 | docker build -t /laravel-application:0.1.0 ./docker/Dockerfile.phpfpm 40 | 41 | # You might have to login to push image in docker repository. 42 | docker login 43 | 44 | # Push image to your private repository 45 | docker push /laravel-application:0.1.0 46 | ``` 47 | 48 | Create Nginx image 49 | 50 | ``` 51 | docker build -t /fellowship-nginx:0.0.3 ./docker/Dockerfile.nginx 52 | docker push /fellowship-nginx:0.0.3 53 | ``` 54 | 55 | Now, that you have all required images in docker repository, you can install/update 56 | helm chart by running below command from root directory. 57 | 58 | ``` 59 | bash ./bin/publish_chart.sh 60 | ``` 61 | -------------------------------------------------------------------------------- /bin/install-project.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clean up existing docker data -For clean installation 4 | rm -rf docker/laravel 5 | rm -rf docker/db/dbdata 6 | 7 | docker-compose down 8 | 9 | # OPTION 1 10 | # -------------------- # 11 | # Download laravel LTS framework (https://github.com/laravel/laravel/releases) 12 | LARAVEL_VERSION_NO="5.5.28" 13 | curl -L https://github.com/laravel/laravel/archive/v${LARAVEL_VERSION_NO}.tar.gz | tar xz 14 | mv laravel-${LARAVEL_VERSION_NO} docker/laravel 15 | cp docker/laravel/.env.example docker/laravel/.env 16 | # -------------------- # 17 | 18 | # OPTION 2 19 | # -------------------- # 20 | # OR clone your existing project 21 | #git clone https://github.com/.git laravel 22 | #mv laravel docker/laravel 23 | 24 | # Checkout develop branch for local development purpose 25 | #cd laravel 26 | #git checkout develop 27 | #cd .. 28 | # -------------------- # 29 | 30 | # Create image 31 | docker-compose up --build -d 32 | 33 | # Perform series of action in container 34 | APP_NAME="laravel_php_fpm" 35 | 36 | docker-compose exec $APP_NAME composer install 37 | 38 | docker-compose exec $APP_NAME php artisan key:generate 39 | 40 | docker-compose exec $APP_NAME node -v 41 | 42 | docker-compose exec $APP_NAME npm install 43 | 44 | docker-compose exec $APP_NAME npm run dev 45 | 46 | # Ensure database is ready to handel php artisan command 47 | sleep 3 48 | 49 | docker-compose exec $APP_NAME php artisan optimize 50 | 51 | docker-compose exec $APP_NAME php artisan migrate 52 | 53 | docker-compose exec $APP_NAME vendor/bin/phpunit -------------------------------------------------------------------------------- /bin/publish_chart.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | 4 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ); 5 | 6 | DIR_ROOT="${DIR/\/bin/}"; 7 | 8 | export ENVIRONMENT_LOCAL="local"; 9 | export ENVIRONMENT_TEST="tst"; 10 | 11 | 12 | 13 | # 14 | # Apply chart into the test environment with the testing container image or 15 | # production one based on the current branch. The replica set used in the 16 | # previous release will stick around after the release has been completed, this 17 | # is a known bug. 18 | # 19 | 20 | 21 | ENV_CHART_NAME="laravel"; 22 | VERSION_NUMBER="0.1.0" 23 | 24 | echo "Waiting for update to complete, this may take a couple of minutes..."; 25 | helm upgrade \ 26 | --kube-context="${ENV_CHART_NAME}" \ 27 | --install \ 28 | --values "${DIR_ROOT}/chart/values.yaml" \ 29 | --set image.tag="${VERSION_NUMBER}" \ 30 | --set database.password="laravel_password" \ 31 | --wait \ 32 | "${ENV_CHART_NAME}" \ 33 | "${DIR_ROOT}/chart"; 34 | 35 | echo "Helm chart applied successfully."; 36 | -------------------------------------------------------------------------------- /chart/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | -------------------------------------------------------------------------------- /chart/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "0.1.0" 3 | description: Helm chart used for deploying Laravel Application. 4 | name: laravel 5 | version: 0.1.0 6 | -------------------------------------------------------------------------------- /chart/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | 1. Get the application URL by running these commands: 2 | {{- if .Values.ingress.enabled }} 3 | {{- range .Values.ingress.hosts }} 4 | http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} 5 | {{- end }} 6 | {{- else if contains "NodePort" .Values.phpfpmService.type }} 7 | export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fellowship.fullname" . }}) 8 | export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") 9 | echo http://$NODE_IP:$NODE_PORT 10 | {{- else if contains "LoadBalancer" .Values.phpfpmService.type }} 11 | NOTE: It may take a few minutes for the LoadBalancer IP to be available. 12 | You can watch the status of by running 'kubectl get svc -w {{ template "fellowship.fullname" . }}' 13 | export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fellowship.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') 14 | echo http://$SERVICE_IP:{{ .Values.phpfpmService.port }} 15 | {{- else if contains "ClusterIP" .Values.phpfpmService.type }} 16 | export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fellowship.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") 17 | echo "Visit http://127.0.0.1:8080 to use your application" 18 | kubectl port-forward $POD_NAME 8080:80 19 | {{- end }} 20 | -------------------------------------------------------------------------------- /chart/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "fellowship.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | If release name contains chart name it will be used as a full name. 13 | */}} 14 | {{- define "fellowship.fullname" -}} 15 | {{- if .Values.fullnameOverride -}} 16 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} 17 | {{- else -}} 18 | {{- $name := default .Chart.Name .Values.nameOverride -}} 19 | {{- if contains $name .Release.Name -}} 20 | {{- .Release.Name | trunc 63 | trimSuffix "-" -}} 21 | {{- else -}} 22 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 23 | {{- end -}} 24 | {{- end -}} 25 | {{- end -}} 26 | 27 | {{/* 28 | Create chart name and version as used by the chart label. 29 | */}} 30 | {{- define "fellowship.chart" -}} 31 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} 32 | {{- end -}} 33 | -------------------------------------------------------------------------------- /chart/templates/configMap.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ template "laravel.fullname" . }}-nginx-vhost 5 | labels: 6 | app: {{ template "laravel.name" . }}-nginx-vhost 7 | chart: {{ template "laravel.chart" . }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | data: 11 | laravel.conf: |- 12 | server { 13 | listen {{ .Values.nginxService.internalPort }}; 14 | listen [::]:{{ .Values.nginxService.internalPort }}; 15 | 16 | server_name laravel.service.tst.consul; 17 | root /laravel/public; 18 | index index.php index.html index.htm; 19 | 20 | location / { 21 | try_files $uri /index.php?$args; 22 | } 23 | 24 | location ~ \.php$ { 25 | fastcgi_pass 127.0.0.1:9000; 26 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 27 | fastcgi_index index.php; 28 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 29 | include fastcgi_params; 30 | fastcgi_param PATH_INFO $fastcgi_path_info; 31 | } 32 | 33 | access_log /dev/stdout; 34 | error_log /dev/stderr; 35 | } 36 | -------------------------------------------------------------------------------- /chart/templates/db-secrets.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Secret 3 | metadata: 4 | name: {{ template "laravel.fullname" . }}-db 5 | labels: 6 | app: {{ template "laravel.name" . }} 7 | chart: {{ template "laravel.chart" . }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | type: Opaque 11 | data: 12 | db-host: {{ .Values.database.host | b64enc | quote }} 13 | db-name: {{ .Values.database.name | b64enc | quote }} 14 | db-password: {{ .Values.database.password | b64enc | quote }} 15 | db-user: {{ .Values.database.user | b64enc | quote }} 16 | -------------------------------------------------------------------------------- /chart/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: {{ template "laravel.fullname" . }} 5 | labels: 6 | app: {{ template "laravel.name" . }} 7 | chart: {{ template "laravel.chart" . }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | spec: 11 | replicas: {{ .Values.replicaCount }} 12 | selector: 13 | matchLabels: 14 | app: {{ template "laravel.name" . }} 15 | release: {{ .Release.Name }} 16 | template: 17 | metadata: 18 | labels: 19 | app: {{ template "laravel.name" . }} 20 | release: {{ .Release.Name }} 21 | spec: 22 | volumes: 23 | - name: source-code 24 | emptyDir: {} 25 | - name: nginx-vhost 26 | configMap: 27 | name: {{ template "laravel.name" . }}-nginx-vhost 28 | containers: 29 | # Nginx Container 30 | - name: {{ .Chart.Name }}-nginx 31 | image: "example-docker-register-server/laravel-nginx:0.1.0" 32 | #image: "nginx:alpine" 33 | imagePullPolicy: {{ .Values.image.pullPolicy }} 34 | ports: 35 | - name: http 36 | containerPort: {{ .Values.nginxService.internalPort }} 37 | volumeMounts: 38 | - name: nginx-vhost 39 | mountPath: /etc/nginx/conf.d 40 | - name: source-code 41 | mountPath: /var/www/laravel/ 42 | # PHPfpm Container 43 | - name: {{ .Chart.Name }}-phpfpm 44 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" 45 | imagePullPolicy: {{ .Values.image.pullPolicy }} 46 | lifecycle: 47 | postStart: 48 | exec: 49 | command: ["/bin/sh", "-c", "cp -r /var/www/laravel/. /laravel"] 50 | ports: 51 | - name: http-phpfpm 52 | containerPort: {{ .Values.phpfpmService.port }} 53 | protocol: TCP 54 | volumeMounts: 55 | - name: source-code 56 | mountPath: /laravel 57 | -------------------------------------------------------------------------------- /chart/templates/ingress.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.ingress.enabled -}} 2 | {{- $fullName := include "laravel.fullname" . -}} 3 | {{- $ingressPath := .Values.ingress.path -}} 4 | apiVersion: extensions/v1beta1 5 | kind: Ingress 6 | metadata: 7 | name: {{ $fullName }} 8 | labels: 9 | app: {{ template "laravel.name" . }} 10 | chart: {{ template "laravel.chart" . }} 11 | release: {{ .Release.Name }} 12 | heritage: {{ .Release.Service }} 13 | {{- with .Values.ingress.annotations }} 14 | annotations: 15 | {{ toYaml . | indent 4 }} 16 | {{- end }} 17 | spec: 18 | {{- if .Values.ingress.tls }} 19 | tls: 20 | {{- range .Values.ingress.tls }} 21 | - hosts: 22 | {{- range .hosts }} 23 | - {{ . }} 24 | {{- end }} 25 | secretName: {{ .secretName }} 26 | {{- end }} 27 | {{- end }} 28 | rules: 29 | {{- range .Values.ingress.hosts }} 30 | - host: {{ . }} 31 | http: 32 | paths: 33 | - path: {{ $ingressPath }} 34 | backend: 35 | serviceName: {{ $fullName }} 36 | servicePort: http 37 | {{- end }} 38 | {{- end }} 39 | -------------------------------------------------------------------------------- /chart/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ template "laravel.fullname" . }} 5 | labels: 6 | app: {{ template "laravel.name" . }} 7 | chart: {{ template "laravel.chart" . }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | spec: 11 | type: {{ .Values.nginxService.type }} 12 | ports: 13 | - port: {{ .Values.nginxService.externalPort }} 14 | targetPort: {{ .Values.nginxService.internalPort }} 15 | protocol: TCP 16 | name: http 17 | selector: 18 | app: {{ template "laravel.name" . }} 19 | release: {{ .Release.Name }} 20 | -------------------------------------------------------------------------------- /chart/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for fellowship Test Environment. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | replicaCount: 1 6 | 7 | image: 8 | repository: example-docker-register-server/laravel-application 9 | tag: 0.1.0 10 | pullPolicy: IfNotPresent 11 | 12 | database: 13 | host: mariadb-mariadb.db 14 | # User could not be the same as db name due to a max length issue. 15 | user: laravel_user 16 | password: "" # Defined at apply time. 17 | name: laravel_tst 18 | 19 | nginxService: 20 | name: nginx 21 | type: NodePort 22 | externalPort: 80 23 | internalPort: 80 24 | 25 | phpfpmService: 26 | name: phpfpm 27 | type: NodePort 28 | port: 9000 29 | 30 | ingress: 31 | enabled: true 32 | annotations: 33 | kubernetes.io/ingress.class: traefik 34 | path: / 35 | hosts: 36 | - laravel.service.tst.consul 37 | tls: [] 38 | 39 | resources: {} 40 | # We usually recommend not to specify default resources and to leave this as a conscious 41 | # choice for the user. This also increases chances charts run on environments with little 42 | # resources, such as Minikube. If you do want to specify resources, uncomment the following 43 | # lines, adjust them as necessary, and remove the curly braces after 'resources:'. 44 | # limits: 45 | # cpu: 100m 46 | # memory: 128Mi 47 | # requests: 48 | # cpu: 100m 49 | # memory: 128Mi 50 | 51 | nodeSelector: {} 52 | 53 | tolerations: [] 54 | 55 | affinity: {} 56 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | services: 4 | # Laravel application 5 | laravel_php_fpm: 6 | build: 7 | context: ./docker 8 | dockerfile: "Dockerfile.phpfpm" 9 | container_name: laravel-phpfpm 10 | volumes: 11 | - ./docker/laravel:/var/www/laravel 12 | links: 13 | - laravel_database 14 | ports: 15 | - 9010:9000 16 | depends_on: 17 | - laravel_database 18 | environment: 19 | - DB_PORT=3306 20 | - DB_HOST=laravel_database 21 | 22 | # Webserver 23 | nginx: 24 | build: 25 | context: ./docker 26 | dockerfile: Dockerfile.nginx 27 | container_name: laravel-nginx 28 | ports: 29 | - "82:80" 30 | links: 31 | - laravel_php_fpm 32 | volumes_from: 33 | - laravel_php_fpm 34 | volumes: 35 | - ./docker/logs/nginx/:/var/log/nginx 36 | restart: always 37 | 38 | # The Database 39 | laravel_database: 40 | image: mariadb:10.2 41 | container_name: laravel-mysql 42 | volumes: 43 | - "./docker/db:/docker-entrypoint-initdb.d" 44 | - "./docker/db/dbdata:/var/lib/mysql" 45 | environment: 46 | - "MYSQL_DATABASE=homestead" 47 | - "MYSQL_USER=homestead" 48 | - "MYSQL_PASSWORD=secret" 49 | - "MYSQL_ROOT_PASSWORD=root" 50 | ports: 51 | - "33063:3306" 52 | restart: always 53 | -------------------------------------------------------------------------------- /docker/Dockerfile.nginx: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | 3 | COPY conf/nginx.conf /etc/nginx/ 4 | COPY conf/laravel.conf /etc/nginx/sites-available/ 5 | 6 | RUN apk update \ 7 | && apk upgrade \ 8 | && apk add --no-cache openssl \ 9 | && apk add --no-cache bash \ 10 | && adduser -D -H -u 1000 -s /bin/bash www-data -G www-data 11 | 12 | ARG PHP_UPSTREAM_CONTAINER=laravel-phpfpm 13 | ARG PHP_UPSTREAM_PORT=9000 14 | 15 | # Set upstream conf and remove the default conf 16 | RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \ 17 | && rm /etc/nginx/conf.d/default.conf 18 | 19 | EXPOSE 80 443 20 | -------------------------------------------------------------------------------- /docker/Dockerfile.phpfpm: -------------------------------------------------------------------------------- 1 | FROM php:7.2-fpm 2 | 3 | ENV WORKDIR=/var/www/laravel \ 4 | NODE_VERSION=8.11.1 5 | 6 | # Install common tools and libraries 7 | RUN apt-get update && apt-get install -y --no-install-recommends \ 8 | curl \ 9 | git \ 10 | zip \ 11 | unzip \ 12 | vim \ 13 | openssl \ 14 | libz-dev \ 15 | libjpeg-dev \ 16 | libmcrypt-dev \ 17 | autoconf \ 18 | file \ 19 | g++ \ 20 | gcc \ 21 | gnupg 22 | 23 | # Install PHP database modules 24 | RUN docker-php-ext-install pdo pdo_mysql mysqli 25 | 26 | # Install PHP intl module 27 | RUN apt-get update && apt-get install -y libicu-dev \ 28 | && docker-php-ext-configure intl \ 29 | && docker-php-ext-install intl 30 | 31 | # Install PHP Image module and libraries 32 | RUN apt-get update && apt-get install -y \ 33 | libfreetype6-dev libjpeg62-turbo-dev libpng-dev libgd-dev \ 34 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 35 | && docker-php-ext-install gd \ 36 | && docker-php-ext-install exif 37 | 38 | # Install PHP String module 39 | RUN docker-php-ext-install mbstring 40 | 41 | # Install Xdebug and Redis 42 | #RUN docker-php-source extract \ 43 | # && pecl install xdebug-alpha redis \ 44 | # && docker-php-ext-enable xdebug redis \ 45 | # && docker-php-source delete 46 | 47 | # PHP Zip Archive 48 | RUN apt-get install -y zlib1g-dev \ 49 | && docker-php-ext-install zip 50 | 51 | # Install composer 52 | RUN curl -sS https://getcomposer.org/installer | \ 53 | php -- --install-dir=/usr/local/bin --filename=composer 54 | 55 | # Install Node.js (LTS version 8.11.1) 56 | RUN curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \ 57 | && tar -xJf "node-v$NODE_VERSION-linux-x64.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \ 58 | && rm "node-v$NODE_VERSION-linux-x64.tar.xz" \ 59 | && ln -s /usr/local/bin/node /usr/local/bin/nodejs \ 60 | && node -v \ 61 | && npm -v 62 | 63 | # Set your timezone here 64 | RUN rm /etc/localtime 65 | RUN ln -s /usr/share/zoneinfo/Australia/Brisbane /etc/localtime 66 | RUN "date" 67 | 68 | # Clean 69 | RUN apt-get clean 70 | RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/cache/* 71 | 72 | COPY ./conf/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini 73 | COPY ./conf/php.ini /usr/local/etc/php/conf.d/php.ini 74 | 75 | RUN mkdir -p ${WORKDIR} 76 | 77 | COPY ./laravel ${WORDIR} 78 | 79 | WORKDIR ${WORKDIR} 80 | -------------------------------------------------------------------------------- /docker/conf/laravel.conf: -------------------------------------------------------------------------------- 1 | server { 2 | 3 | listen 80; 4 | listen [::]:80; 5 | 6 | # For https 7 | # listen 443 ssl; 8 | # listen [::]:443 ssl ipv6only=on; 9 | # ssl_certificate /etc/nginx/ssl/default.crt; 10 | # ssl_certificate_key /etc/nginx/ssl/default.key; 11 | server_name dev.laravel; 12 | root /var/www/laravel/public; 13 | index index.php index.html index.htm; 14 | 15 | location / { 16 | try_files $uri $uri/ /index.php?$query_string; 17 | } 18 | 19 | location ~ \.php$ { 20 | fastcgi_pass php-upstream; 21 | fastcgi_index index.php; 22 | fastcgi_buffers 16 16k; 23 | fastcgi_buffer_size 32k; 24 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 25 | #fixes timeouts 26 | fastcgi_read_timeout 600; 27 | include fastcgi_params; 28 | } 29 | 30 | location ~ /\.ht { 31 | deny all; 32 | } 33 | 34 | error_log /var/log/nginx/laravel_error.log; 35 | access_log /var/log/nginx/laravel_access.log; 36 | } 37 | -------------------------------------------------------------------------------- /docker/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | user www-data; 2 | worker_processes 4; 3 | pid /run/nginx.pid; 4 | #daemon off; 5 | 6 | events { 7 | worker_connections 2048; 8 | multi_accept on; 9 | use epoll; 10 | } 11 | 12 | http { 13 | server_tokens off; 14 | sendfile on; 15 | tcp_nopush on; 16 | tcp_nodelay on; 17 | keepalive_timeout 15; 18 | types_hash_max_size 2048; 19 | client_max_body_size 20M; 20 | include /etc/nginx/mime.types; 21 | default_type application/octet-stream; 22 | access_log /dev/stdout; 23 | error_log /dev/stderr; 24 | gzip on; 25 | gzip_disable "msie6"; 26 | 27 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 28 | ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; 29 | 30 | include /etc/nginx/conf.d/*.conf; 31 | include /etc/nginx/sites-available/*.conf; 32 | open_file_cache off; # Disabled for issue 619 33 | charset UTF-8; 34 | } -------------------------------------------------------------------------------- /docker/conf/php.ini: -------------------------------------------------------------------------------- 1 | ; Defines the default timezone used by the date functions 2 | date.timezone = "Australia/Brisbane" 3 | 4 | ; Enable the PHP scripting language engine under Apache. 5 | ; http://php.net/engine 6 | engine = On 7 | 8 | ; Default Value: On 9 | ; Development Value: Off 10 | ; Production Value: Off 11 | ; http://php.net/short-open-tag 12 | short_open_tag = Off 13 | 14 | 15 | ; This directive allows you to disable certain functions for security reasons. 16 | ; It receives a comma-delimited list of function names. 17 | ; http://php.net/disable-functions 18 | ; pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, 19 | disable_functions = 20 | 21 | 22 | ; Decides whether PHP may expose the fact that it is installed on the server 23 | expose_php = Off 24 | 25 | 26 | ; Maximum execution time of each script, in seconds 27 | ;max_execution_time = 30 28 | max_execution_time = 300 29 | 30 | ; Maximum amount of time each script may spend parsing request data. It's a good 31 | ; idea to limit this time on productions servers in order to eliminate unexpectedly 32 | ; long running scripts. 33 | ; Default Value: -1 (Unlimited) 34 | ; Development Value: 60 (60 seconds) 35 | ; Production Value: 60 (60 seconds) 36 | max_input_time = 60 37 | 38 | ; Maximum amount of memory a script may consume (128MB) 39 | memory_limit = 256M 40 | 41 | 42 | ; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED 43 | ; Development Value: E_ALL 44 | ; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT 45 | ; http://php.net/error-reporting 46 | error_reporting = E_ALL 47 | 48 | ; This directive controls whether or not and where PHP will output errors, 49 | ; notices and warnings too. 50 | ; Default Value: On 51 | ; Development Value: On 52 | ; Production Value: Off 53 | display_errors = On 54 | 55 | ; The display of errors which occur during PHP's startup sequence are handled 56 | ; separately from display_errors. 57 | ; Default Value: Off 58 | ; Development Value: On 59 | ; Production Value: Off 60 | display_startup_errors = On 61 | 62 | ; Default Value: Off 63 | ; Development Value: On 64 | ; Production Value: On 65 | log_errors = On 66 | 67 | ; Set maximum length of log_errors. In error_log information about the source is 68 | ; added. The default is 1024 and 0 allows to not apply any maximum length at all. 69 | log_errors_max_len = 1024 70 | 71 | ; Do not log repeated messages. Repeated errors must occur in same file on same 72 | ; line unless ignore_repeated_source is set true. 73 | ignore_repeated_errors = Off 74 | 75 | ; Ignore source of message when ignoring repeated messages. When this setting 76 | ; is On you will not log errors with repeated messages from different files or 77 | ; source lines. 78 | ignore_repeated_source = Off 79 | 80 | ; If this parameter is set to Off, then memory leaks will not be shown (on 81 | ; stdout or in the log). This has only effect in a debug compile, and if 82 | ; error reporting includes E_WARNING in the allowed list 83 | report_memleaks = On 84 | 85 | ; Log errors to specified file. PHP's default behavior is to leave this value 86 | ; empty. 87 | error_log = /var/log/php_errors.log 88 | 89 | 90 | ; Maximum size of POST data that PHP will accept. 91 | ; Its value may be 0 to disable the limit. It is ignored if POST data reading 92 | ; is disabled through enable_post_data_reading. 93 | post_max_size = 128M 94 | 95 | ; Whether to allow HTTP file uploads. 96 | file_uploads = On 97 | 98 | ; Maximum allowed size for uploaded files. 99 | upload_max_filesize = 100M 100 | 101 | ; Maximum number of files that can be uploaded via a single request 102 | max_file_uploads = 20 103 | 104 | 105 | ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. 106 | allow_url_fopen = On 107 | 108 | ; Whether to allow include/require to open URLs (like http:// or ftp://) as files. 109 | allow_url_include = Off 110 | 111 | 112 | [mail function] 113 | ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). 114 | sendmail_path = /usr/sbin/sendmail -t -i 115 | 116 | ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename 117 | mail.add_x_header = On 118 | 119 | ; The path to a log file that will log all mail() calls. Log entries include 120 | ; the full path of the script, line number, To address and headers. 121 | mail.log = /var/log/maillogs.log 122 | 123 | 124 | [Session] 125 | ; Handler used to store/retrieve data. 126 | session.save_handler = files 127 | 128 | ;session.save_path = "/var/lib/php/sessions" 129 | ;session.save_path = "/tmp" 130 | 131 | ; Whether to use strict session mode. 132 | session.use_strict_mode = 0 133 | 134 | ; Name of the session (used as cookie name). 135 | session.name = PHPSESSID 136 | 137 | ; Initialize session on request startup. 138 | session.auto_start = 0 139 | 140 | ; Whether to use cookies. 141 | session.use_cookies = 1 142 | session.use_only_cookies = 1 143 | session.cookie_lifetime = 0 144 | session.cookie_path = / 145 | session.cookie_httponly = 146 | 147 | ; Handler used to serialize data. php is the standard serializer of PHP. 148 | session.serialize_handler = php 149 | 150 | ; Garbage collection settings 151 | session.gc_probability = 1 152 | session.gc_divisor = 1000 153 | session.gc_maxlifetime = 1440 154 | 155 | ; Specified here to create the session id 156 | session.entropy_file = /dev/urandom 157 | session.entropy_length = 32 158 | 159 | ; Session hash 160 | session.hash_function = sha512 161 | session.hash_bits_per_character = 5 162 | 163 | ; Set to {nocache,private,public,} to determine HTTP caching aspects 164 | ; or leave this empty to avoid sending anti-caching headers. 165 | session.cache_limiter = nocache 166 | session.cache_expire = 180 167 | 168 | session.use_trans_sid = 0 169 | -------------------------------------------------------------------------------- /docker/conf/xdebug.ini: -------------------------------------------------------------------------------- 1 | ; xdebug.remote_host=dockerhost 2 | xdebug.remote_connect_back=1 3 | xdebug.remote_port=9000 4 | xdebug.idekey=PHPSTORM 5 | xdebug.remote_log="/tmp/xdebug_log/xdebug.log" 6 | 7 | xdebug.remote_autostart=0 8 | xdebug.remote_enable=0 9 | xdebug.cli_color=0 10 | xdebug.profiler_enable=0 11 | xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp/profiling" 12 | 13 | xdebug.remote_handler=dbgp 14 | xdebug.remote_mode=req 15 | 16 | xdebug.var_display_max_children=-1 17 | xdebug.var_display_max_data=-1 18 | xdebug.var_display_max_depth=-1 19 | -------------------------------------------------------------------------------- /docker/db/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dambergautam/laravel-kubernetes-helm/16d97ed14d6beb68db1a4a5aabf89378e9c78688/docker/db/.keep -------------------------------------------------------------------------------- /docker/laravel/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dambergautam/laravel-kubernetes-helm/16d97ed14d6beb68db1a4a5aabf89378e9c78688/docker/laravel/.keep -------------------------------------------------------------------------------- /laravel-homepage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dambergautam/laravel-kubernetes-helm/16d97ed14d6beb68db1a4a5aabf89378e9c78688/laravel-homepage.png --------------------------------------------------------------------------------