Replace Vagrant with Docker

This commit is contained in:
Anton Vakhrushev 2017-12-02 23:10:55 +03:00
parent 9b3fdf386b
commit 895c7b0b29
19 changed files with 3375 additions and 111 deletions

View File

@ -12,5 +12,8 @@ indent_size = 2
[gulpfile.js]
indent_size = 2
[package.json]
indent_size = 2
[Makefile]
indent_style = tab

1
.env Normal file
View File

@ -0,0 +1 @@
HOMEPAGE_IMAGE=homepage-php

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
.composer
.npm
.vagrant
/ansible/galaxy.roles/
/output_*
/node_modules/

25
Dockerfile Normal file
View File

@ -0,0 +1,25 @@
FROM php:7.2-cli
# Project folder
RUN mkdir -p /var/homepage
WORKDIR /srv/homepage
RUN apt-get update \
&& apt-get install -y git gnupg \
&& rm -rf /var/lib/apt/lists/*
# get composer and required tools
RUN curl -sLO https://getcomposer.org/download/1.5.2/composer.phar \
&& mv composer.phar /usr/local/bin/composer \
&& chmod +x /usr/local/bin/composer
# Deployer
RUN curl -sLO https://deployer.org/releases/v6.0.3/deployer.phar \
&& mv deployer.phar /usr/local/bin/dep \
&& chmod +x /usr/local/bin/dep
# install npm
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/*

View File

@ -1,13 +1,17 @@
build:
clean-files:
rm -rf output_dev/*
vendor/bin/sculpin generate --env=dev --no-interaction
BUILD_ENV=dev node_modules/.bin/gulp build
deploy:
rm -rf output_prod/*
vendor/bin/sculpin generate --env=prod --no-interaction
BUILD_ENV=prod node_modules/.bin/gulp build
build: clean-files
./tools/sculpin generate --env=dev --no-interaction
./tools/npm build
deploy: clean-files
./tools/sculpin generate --env=prod --no-interaction
./tools/npm build-prod
deployer deploy production
rollback:
deployer rollback production
docker-build:
docker build --tag homepage-php .

23
Vagrantfile vendored
View File

@ -1,23 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV["LC_ALL"] = "en_US.UTF-8"
# For installing ansible_local from pip on guest
Vagrant.require_version ">= 1.8.3"
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.provision "ansible_local" do |ansible|
ansible.playbook = "ansible/vagrant-provision.yml"
ansible.galaxy_role_file = "ansible/vagrant-requirements.yml"
ansible.galaxy_roles_path = "ansible/galaxy.roles"
ansible.sudo = true
end
config.ssh.forward_agent = true
end

View File

@ -1,6 +0,0 @@
---
- name: Create nginx config
template:
src: site.conf.j2
dest: /etc/nginx/sites-enabled/{{ nginx_conf_name }}
notify: restart nginx

View File

@ -1,14 +0,0 @@
server {
listen 80;
server_name {{ nginx_conf_domain }} www.{{ nginx_conf_domain }};
location / {
root {{ nginx_conf_root }};
index index.html;
try_files $uri $uri/ =404;
}
{% if not nginx_conf_sendfile|default(true) %}
sendfile off;
{% endif %}
}

View File

@ -1,11 +0,0 @@
---
- name: Update apt cache
apt: update_cache=yes
- name: Install system packages
apt: pkg={{ item }} state=latest
with_items:
- curl
- wget
- python-software-properties
- git

View File

@ -1,34 +0,0 @@
---
- hosts: all
vars:
application_root: /vagrant
timezone: UTC
nginx_conf_name: anwinged.conf
nginx_conf_root: '{{ application_root }}/output_dev'
nginx_conf_domain: anwinged.ru
nginx_conf_sendfile: false
nginx_remove_default_vhost: true
php_enable_webserver: false
php_packages:
- php7.1
- php7.1-mbstring
- php7.1-intl
- php7.1-curl
- php7.1-xml
pre_tasks:
- name: Ensure that PHP Ondrej PPA is added
apt_repository: repo=ppa:ondrej/php state=present
roles:
- yatesr.timezone
- server
- geerlingguy.nginx
- nginx
- geerlingguy.php

View File

@ -1,12 +0,0 @@
---
- src: yatesr.timezone
version: 1.0.0
- src: geerlingguy.nginx
version: 1.9.6
- src: geerlingguy.php
version: 3.4.2
- src: geerlingguy.composer
version: 1.5.0

View File

@ -34,6 +34,6 @@ gulp.task('build', function () {
;
});
// gulp.task('build:watch', function () {
// gulp.watch(SASS_SOURCE_PATH, ['build']);
// });
gulp.task('build:watch', function () {
gulp.watch(SASS_SOURCE_PATH, ['build']);
});

3262
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,5 +9,10 @@
"gulp-autoprefixer": "^3.1.1",
"gulp-concat": "^2.6.1",
"gulp-sass": "^3.1.0"
},
"scripts": {
"build": "BUILD_ENV=dev gulp build",
"watch": "BUILD_ENV=dev gulp build:watch",
"build-prod": "BUILD_ENV=prod gulp build"
}
}

View File

@ -4,7 +4,6 @@
justify-content: center;
height: 100vh;
&__note {
text-align: center;
font-size: 120%;

17
tools/composer Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
source .env
mkdir -p ./.composer/cache
docker run \
--rm \
--interactive \
--tty \
--user $UID:$(id -g) \
--volume /etc/passwd:/etc/passwd:ro \
--volume /etc/group:/etc/group:ro \
--volume $PWD:/srv/homepage \
--volume $PWD/.composer:/tmp/.composer \
--env COMPOSER_HOME=/tmp/.composer \
${HOMEPAGE_IMAGE} composer "$@"

15
tools/dep Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
source .env
docker run \
--rm \
--user "$UID" \
--volume /etc/passwd:/etc/passwd:ro \
--volume /etc/group:/etc/group:ro \
--volume $SSH_AUTH_SOCK:/ssh-agent --env SSH_AUTH_SOCK=/ssh-agent \
--volume "$PWD:/srv/homepage" \
--interactive \
--tty \
${HOMEPAGE_IMAGE} \
dep "$@"

15
tools/npm Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
source .env
mkdir -p ./.npm
docker run \
--rm \
--interactive \
--tty \
--user $UID:$(id -g) \
--volume $PWD:/srv/homepage \
--volume $PWD/.npm:/tpm/.npm \
--env npm_config_cache=/tmp/.npm \
${HOMEPAGE_IMAGE} npm "$@"

15
tools/sculpin Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
source .env
docker run \
--rm \
--user "$UID" \
--init \
--volume="$PWD:/srv/homepage" \
--expose=8000 \
--publish=8000:8000 \
--interactive \
--tty \
${HOMEPAGE_IMAGE} \
./vendor/bin/sculpin "$@"