-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9faf3f
commit b333dda
Showing
25 changed files
with
1,126 additions
and
262 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
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
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 |
---|---|---|
|
@@ -9,4 +9,5 @@ Homestead.yaml | |
/public/gzero/* | ||
tests/_output/* | ||
.phpstorm.meta.php | ||
_ide_helper.php | ||
_ide_helper.php | ||
.vscode |
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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
server { | ||
listen 80; | ||
server_name "www.{{DEFAULT_HOST}}"; | ||
return 301 http://{{DEFAULT_HOST}}$request_uri; | ||
} | ||
server { | ||
listen 80; | ||
server_name .{{DEFAULT_HOST}}; | ||
|
||
root /var/www/public; | ||
index index.php; | ||
|
||
# Cache everything for better performance | ||
location ~* \.(jpg|jpeg|png|gif|ico|svg|woff|woff2|css|js)$ { | ||
expires 14d; | ||
} | ||
|
||
# Disable sendfile - https://docs.vagrantup.com/v2/synced-folders/virtualbox.html | ||
sendfile off; | ||
|
||
location = /favicon.ico { access_log off; log_not_found off; } | ||
location = /robots.txt { access_log off; log_not_found off; } | ||
|
||
# Stdout logging | ||
error_log /dev/stdout info; | ||
access_log /dev/stdout; | ||
|
||
# Remove index.php$ | ||
if ($request_uri ~* "^(.*/)index\.php$") { | ||
return 301 $1; | ||
} | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
|
||
# Remove from everywhere index.php | ||
if ($request_uri ~* "^(.*/)index\.php(/?)(.*)") { | ||
return 301 $1$3; | ||
} | ||
} | ||
|
||
# Remove trailing slash. | ||
if (!-d $request_filename) { | ||
rewrite ^/(.+)/$ /$1 permanent; | ||
} | ||
|
||
# Clean Double Slashes | ||
if ($request_uri ~* "\/\/") { | ||
rewrite ^/(.*) /$1 permanent; | ||
} | ||
|
||
location ~ \.php$ { | ||
try_files $uri = 404; | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass unix:/var/run/php7.1-fpm.sock; | ||
fastcgi_index index.php; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
include fastcgi_params; | ||
} | ||
|
||
# deny access to . files, for security | ||
# | ||
location ~ /\. { | ||
log_not_found off; | ||
deny all; | ||
} | ||
} | ||
server { | ||
listen 80; | ||
server_name _; | ||
rewrite ^ http://{{DEFAULT_HOST}}$request_uri permanent; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
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,7 +1,8 @@ | ||
FROM gzero/platform-container:v2 | ||
FROM gzero/platform-container:v3 | ||
|
||
MAINTAINER Adrian Skierniewski <adrian.skierniewski@gmail.com> | ||
|
||
COPY . /var/www/ | ||
COPY ./.server/nginx/site.conf /etc/nginx/conf.d/site.template | ||
|
||
RUN chown www-data:www-data -R /var/www |
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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
- hosts: all | ||
remote_user: root | ||
tasks: | ||
- name: Create directories | ||
file: | ||
path: "{{ item.path }}" | ||
state: directory | ||
owner: www-data | ||
group: www-data | ||
mode: 0755 | ||
with_items: | ||
- { path: '/root/backups'} | ||
- { path: '/root/backups/deployment'} | ||
- { path: '/root/production'} | ||
- { path: '/root/production/volumes'} | ||
- { path: '/root/production/volumes/certs'} | ||
- { path: '/root/production/volumes/conf.d'} | ||
- { path: '/root/production/volumes/vhost.d'} | ||
- { path: '/root/production/volumes/templates'} | ||
- name: 'Ensure that database exists' | ||
become: true | ||
become_user: postgres | ||
postgresql_db: | ||
name: "{{ POSTGRES_DATABASE }}" | ||
encoding: UTF-8 | ||
lc_collate: pl_PL.UTF-8 | ||
lc_ctype: pl_PL.UTF-8 | ||
template: template0 | ||
- name: 'Ensure that database user exists' | ||
become: true | ||
become_user: postgres | ||
postgresql_user: | ||
db: "{{ POSTGRES_DATABASE }}" | ||
name: "{{ POSTGRES_USER }}" | ||
password: "{{ POSTGRES_PASSWORD }}" | ||
priv: "ALL" | ||
- name: Backup database | ||
become: true | ||
become_user: postgres | ||
shell: > | ||
pg_dump --clean --if-exists {{ POSTGRES_DATABASE }} | | ||
gzip > {{ POSTGRES_DATABASE }}_$(date +%Y%m%d_%H%M).sql.gz | ||
- name: Move backup to backups dir | ||
shell: > | ||
mv /var/lib/postgresql/{{ POSTGRES_DATABASE }}_$(date +%Y%m%d_%H%M).sql.gz | ||
/root/backups/deployment/{{ POSTGRES_DATABASE }}_$(date +%Y%m%d_%H%M).sql.gz | ||
- name: Copy nginx proxy template file | ||
copy: | ||
src: ./templates/nginx-proxy.tmpl | ||
dest: /root/production/volumes/templates/nginx.tmpl | ||
owner: www-data | ||
group: www-data | ||
mode: 0644 | ||
- name: Copy docker-compose file | ||
template: | ||
src: ../templates/production-compose.yml | ||
dest: /root/production/docker-compose.yml | ||
force: yes | ||
- name: Copy env file | ||
template: | ||
src: ../templates/env.j2 | ||
dest: /root/production/env | ||
force: yes | ||
- name: Stop existing containers | ||
docker_service: | ||
project_src: production | ||
state: absent | ||
remove_images: local | ||
remove_volumes: true | ||
- name: Run docker & docker-compose commands | ||
shell: "{{ item.command }}" | ||
args: | ||
chdir: /root/production | ||
with_items: | ||
- { command: 'docker-compose pull'} | ||
- { command: 'docker-compose up -d --remove-orphans'} | ||
- { command: 'docker volume ls -qf dangling=true | xargs -r docker volume rm'} # Remove unused volumes | ||
- { command: 'docker images -q --no-trunc | xargs -r docker rmi || true'} # Remove unused images | ||
- name: Wait for docker containers | ||
wait_for: | ||
port: 443 | ||
delay: 15 | ||
state: drained | ||
timeout: 300 | ||
- name: Run migrations | ||
shell: docker-compose exec -T web_server php /var/www/artisan migrate --force | ||
args: | ||
chdir: /root/production |
Oops, something went wrong.