├── .docker
├── nginx-proxy
│ └── etc
│ │ └── nginx
│ │ ├── conf.d
│ │ ├── client_max_body_size.conf
│ │ ├── server_tokens.conf
│ │ └── timeout.conf
│ │ └── vhost.d
│ │ └── default_location
├── tevun-aws
│ ├── Dockerfile
│ └── build.sh
└── tevun
│ ├── Dockerfile
│ ├── build.sh
│ └── etc
│ └── nginx
│ ├── .users
│ ├── nginx.conf
│ ├── ssl
│ ├── server.crt
│ ├── server.csr
│ └── server.key
│ └── tevun.conf
├── .env.sample
├── .gitignore
├── .users.sample
├── PROJECT.md
├── README.md
├── badge.png
├── cgi
├── create.sh
├── destroy.sh
└── ping.sh
├── commands
├── compress
│ ├── do.sh
│ └── undo.sh
├── credential
│ ├── password.sh
│ ├── register.sh
│ ├── ssh.sh
│ └── user.sh
├── database
│ ├── mysql-export.sh
│ └── mysql-import.sh
├── down.sh
├── project
│ ├── create.sh
│ ├── destroy.sh
│ ├── projects.sh
│ └── pull.sh
├── setup.sh
├── start.sh
├── stop.sh
├── up.sh
└── utils
│ ├── colors.sh
│ ├── compose.sh
│ ├── lets-encrypt
│ ├── renew.sh
│ └── status.sh
│ ├── ps.sh
│ └── ubuntu
│ └── locale.sh
├── composer.json
├── composer.lock
├── docker-compose.yml.sample
├── images
├── output-create.png
├── output-destroy.png
├── output-register.png
├── output-setup.png
├── pair.jpg
├── setup.png
├── topology.jpg
└── works.png
├── installers
└── ubuntu.sh
├── logo.png
├── logo.svg
├── projects
├── .gitignore
└── index.html
├── samples
├── html
│ ├── app
│ │ ├── .env.stage
│ │ ├── .gitlab-ci.yml
│ │ ├── .tevun
│ │ │ └── hooks
│ │ │ │ ├── install.sh
│ │ │ │ ├── post-checkout.sh
│ │ │ │ ├── pre-checkout.sh
│ │ │ │ └── setup.sh
│ │ ├── docker-compose.yml.stage
│ │ └── public
│ │ │ └── index.html
│ ├── configure.sh
│ └── repo
│ │ └── hooks
│ │ └── post-receive
├── laravel
│ ├── app
│ │ ├── .env.stage
│ │ ├── .gitlab-ci.yml
│ │ ├── .tevun
│ │ │ └── hooks
│ │ │ │ ├── install.sh
│ │ │ │ ├── post-checkout.sh
│ │ │ │ ├── pre-checkout.sh
│ │ │ │ └── setup.sh
│ │ └── docker-compose.yml.stage
│ ├── configure.sh
│ └── repo
│ │ └── hooks
│ │ ├── post-receive
│ │ └── pre-receive
├── php
│ ├── app
│ │ ├── .env.stage
│ │ ├── .gitlab-ci.yml
│ │ ├── .tevun
│ │ │ └── hooks
│ │ │ │ ├── install.sh
│ │ │ │ ├── post-checkout.sh
│ │ │ │ ├── pre-checkout.sh
│ │ │ │ └── setup.sh
│ │ ├── docker-compose.yml.stage
│ │ └── public
│ │ │ └── index.php
│ ├── configure.sh
│ └── repo
│ │ └── hooks
│ │ ├── post-receive
│ │ └── pre-receive
└── wordpress
│ ├── app
│ ├── .env.stage
│ ├── .gitlab-ci.yml
│ ├── .tevun
│ │ └── hooks
│ │ │ ├── install.sh
│ │ │ ├── post-checkout.sh
│ │ │ ├── pre-checkout.sh
│ │ │ └── setup.sh
│ ├── docker-compose.yml.stage
│ └── public
│ │ └── index.php
│ ├── configure.sh
│ └── repo
│ └── hooks
│ ├── post-receive
│ └── pre-receive
├── tevun-functions.sh
└── tevun.sh
/.docker/nginx-proxy/etc/nginx/conf.d/client_max_body_size.conf:
--------------------------------------------------------------------------------
1 | client_max_body_size 0;
2 |
3 |
--------------------------------------------------------------------------------
/.docker/nginx-proxy/etc/nginx/conf.d/server_tokens.conf:
--------------------------------------------------------------------------------
1 | server_tokens off;
2 |
--------------------------------------------------------------------------------
/.docker/nginx-proxy/etc/nginx/conf.d/timeout.conf:
--------------------------------------------------------------------------------
1 | fastcgi_read_timeout 3600;
2 | proxy_read_timeout 3600;
3 | uwsgi_read_timeout 3600;
4 |
5 | fastcgi_buffers 16 32k;
6 | fastcgi_buffer_size 64k;
7 | fastcgi_busy_buffers_size 64k;
8 | proxy_buffer_size 128k;
9 | proxy_buffers 4 256k;
10 | proxy_busy_buffers_size 256k;
11 |
--------------------------------------------------------------------------------
/.docker/nginx-proxy/etc/nginx/vhost.d/default_location:
--------------------------------------------------------------------------------
1 | if ($request_method = 'OPTIONS') {
2 | add_header 'Access-Control-Allow-Origin' "$http_origin" always;
3 | add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always;
4 | add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,Bearer,Device,Context,PrivateToken,Meta' always;
5 | add_header 'Access-Control-Allow-Credentials' 'true' always;
6 |
7 | # required to be able to read Authorization header in frontend
8 | add_header 'Access-Control-Expose-Headers' 'Authorization,Bearer,Device,Context,PrivateToken,Meta';
9 |
10 | # Tell client that this pre-flight info is valid for 20 days
11 | add_header 'Access-Control-Max-Age' 1728000;
12 | add_header 'Content-Type' 'text/plain charset=UTF-8';
13 | add_header 'Content-Length' 0;
14 | return 204;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/.docker/tevun-aws/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM tevun/server:1.0
2 |
3 | RUN apk add --update \
4 | python \
5 | python-dev \
6 | py-pip \
7 | curl \
8 | build-base \
9 | && pip install awscli --upgrade --user \
10 | && apk --purge -v del py-pip \
11 | && rm -rf /var/cache/apk/* \
12 | && ln -s /root/.local/bin/aws /usr/bin/aws
13 |
--------------------------------------------------------------------------------
/.docker/tevun-aws/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | docker build -t tevun/server:aws-${1} .
4 |
5 | docker tag tevun/server:aws-${1} tevun/server:aws-${1}
6 | docker push tevun/server:aws-${1}
7 |
8 | docker tag tevun/server:aws-${1} tevun/server:aws-latest
9 | docker push tevun/server:aws-latest
10 |
--------------------------------------------------------------------------------
/.docker/tevun/Dockerfile:
--------------------------------------------------------------------------------
1 | # small is beautiful
2 | FROM docker:18.06.3-ce
3 |
4 | # The container listens on port 8110, map as needed
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | # This is where the repositories will be stored, and
9 | # should be mounted from the host (or a volume container)
10 | VOLUME ["/app"]
11 |
12 | # We need the following:
13 | # - git, because that gets us the git-http-backend CGI script
14 | # - fcgiwrap, because that is how nginx does CGI
15 | # - spawn-fcgi, to launch fcgiwrap and to create the unix socket
16 | # - nginx, because it is our frontend
17 | RUN apk add --update nginx && \
18 | apk add --update bash && \
19 | apk add --update git && \
20 | apk add --update git-daemon && \
21 | apk add --update fcgiwrap && \
22 | apk add --update spawn-fcgi && \
23 | apk add --update apache2-utils && \
24 | apk add --update py-pip && \
25 | apk add --update python-dev libffi-dev openssl-dev gcc libc-dev make && \
26 | rm -rf /var/cache/apk/*
27 |
28 | COPY ./etc/nginx/.users /etc/nginx/.users
29 | COPY ./etc/nginx/tevun.conf /etc/nginx/tevun.conf
30 | COPY ./etc/nginx/ssl /etc/nginx/ssl
31 | COPY ./etc/nginx/nginx.conf /etc/nginx/nginx.conf
32 |
33 | RUN pip install docker-compose
34 |
35 | RUN addgroup -S tevun && adduser -u 1000 -S tevun -G tevun
36 |
37 | # launch fcgiwrap via spawn-fcgi; launch nginx in the foreground
38 | # so the container doesn't die on us; supposedly we should be
39 | # using supervisord or something like that instead, but this
40 | # will do
41 | CMD spawn-fcgi -s /run/fcgi.sock /usr/bin/fcgiwrap && \
42 | nginx -g "daemon off;"
--------------------------------------------------------------------------------
/.docker/tevun/build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | docker build -t tevun/server .
4 | docker tag tevun/server tevun/server:${1}
5 | docker push tevun/server:${1}
6 | docker push tevun/server:latest
--------------------------------------------------------------------------------
/.docker/tevun/etc/nginx/.users:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/.docker/tevun/etc/nginx/.users
--------------------------------------------------------------------------------
/.docker/tevun/etc/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 | worker_processes 1;
2 |
3 | error_log /var/log/nginx/error.log;
4 | pid /run/nginx.pid;
5 | user root;
6 |
7 | events {
8 | worker_connections 1024;
9 | }
10 |
11 | http {
12 |
13 | server {
14 | server_name tevun;
15 |
16 | listen 80 default_server;
17 | listen [::]:80 default_server;
18 | root /app/projects;
19 |
20 | include "/etc/nginx/tevun.conf";
21 | }
22 |
23 | server {
24 | server_name tevun;
25 |
26 | listen 443 default_server;
27 | listen [::]:443 default_server;
28 | root /app/projects;
29 |
30 | ssl on;
31 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # not possible to do exclusive
32 | ssl_ciphers 'EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA';
33 | ssl_prefer_server_ciphers on;
34 |
35 | ssl_certificate /etc/nginx/ssl/server.crt;
36 | ssl_certificate_key /etc/nginx/ssl/server.key;
37 |
38 | include "/etc/nginx/tevun.conf";
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/.docker/tevun/etc/nginx/ssl/server.crt:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE-----
2 | MIIE1DCCArwCCQDMMwGnSuK0tTANBgkqhkiG9w0BAQsFADAsMRswGQYDVQQKExJE
3 | b2NrZXIgQm9pbGVycGxhdGUxDTALBgNVBAMUBCoudm0wHhcNMTUwNTA0MTcxNDQw
4 | WhcNMjUwNTAxMTcxNDQwWjAsMRswGQYDVQQKExJEb2NrZXIgQm9pbGVycGxhdGUx
5 | DTALBgNVBAMUBCoudm0wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDK
6 | 3TIUiyDvXelWeY9VXMrpjuZtYpVSDsACLpjFUhMnsP5/iKT0VbeZyqHvmwZjAg4G
7 | Y10d+yZDdgv/xeu0HPOFbtR6pCp10d1tdLHZto5Cyuxu7IQsAVjnD6Ko7XFwtNk7
8 | 9o6JZfAFaGL4w5MokrVmCtspnsMZH7/7zU4f96cbF39zLopnpuXGD6t6DA8Qj3gy
9 | 0duaTjs42bYRN+rwLzVKAev99iQ4kPMJn4vV6/Xk6rtoSzC67GQyVZYaFypicD1S
10 | NtsRmgEVvjCBDbrLOneUiRwff6qxEsZi7Hxv7BKFj4iUWnII7K/nP7T6uBHQjHO+
11 | FpsGkU9lCMrCeVFBe8kKz/cbhd+yLUxXwAPr6gSOPmwn232Gy4tozvqZHpbUxsgx
12 | 7sT3ej9K66h1D7J+BjNFWYM1hbnC1r7H/xS7EBzBV8qRoQCVe08Juf5xsouXFakD
13 | clLV4+L+1cxkpwsCQDly5g3tm/TBqA2O+ZJ+YHQDHKkzMyhLs6i0X/M5qvJBiLg1
14 | GLTCS20rpQ5gXTEGuINqHgwXQWkUO6bhgSYqdHGX3zbZ5+qWpI4eui3dHZ1Ll0VH
15 | 6Icpb7ORTQwhc6W8KBlybssYPSlGOEBGUjYGNheoz9FpoSkxCis+P8ZNKtrmpPoq
16 | Su0eOOGFOFHG02eOgPVxSwrDeN9MVJo7BPysGMHJmQIDAQABMA0GCSqGSIb3DQEB
17 | CwUAA4ICAQC63g6NHmQKbiy3G6iaDkpUSbr5Mq2YgU61XnvWVyREqDcy/BXCw9oY
18 | SJ/KUvCpqPnACNOFqjadRAmPiA9nf2WduoCgwQGV/YRFGswSuVvh/3X2TX5NWvbS
19 | t8MQDttQg1dxpiMUjlu3rqhfohBdWJvp2lVSdpDb/MOlXBc/+p7HfOHwhqB7wwPN
20 | NNbSKUbZqZxmD8cOf1X0hASr1yfFPj+2vST3ESaON8S0T2p63YX/sD5jvOUiEuyw
21 | I5WcvLmiRZA07SH8nWyckLY3qWL+OlhSZrlAnolWS00b+7h5LNuRYEjKzwVgntoA
22 | aCopyQih6wIk0+AfJO4sfhJBmQhnIrAaP/zwBH5g9zVizLf5H7U+hNXrMwgw55Sq
23 | vjMdkZHvPKUXTvVit/rYE9H+PY3brkRWzOl4V/i/ZLJJm5805H/NyTbz9kPMJw2Q
24 | nn+KOpfXXySD39f8iuRgSKXsYNul38hxWgcZZ6g+sOOp2n/VUmf0eZUWNnJ8i7AP
25 | 4Qif7aDKMcibOwSwsB+DKZXDvZ5XSdnMphtuLS5rPSL81rVRmWC2DMfQ2eP8j0WN
26 | VTroSk0xedQ7Qr+9TNooi9IyzX6n1a2S1UiciEZ3ZcDbXPl/P01m+IYZyPnLv0+9
27 | ZeioZYh1JLv3/OKsMrMLTfh2ZCj3aXwmc2Owi/wU2LS5QUOMcHH7CQ==
28 | -----END CERTIFICATE-----
29 |
--------------------------------------------------------------------------------
/.docker/tevun/etc/nginx/ssl/server.csr:
--------------------------------------------------------------------------------
1 | -----BEGIN CERTIFICATE REQUEST-----
2 | MIIEcTCCAlkCAQAwLDEbMBkGA1UEChMSRG9ja2VyIEJvaWxlcnBsYXRlMQ0wCwYD
3 | VQQDFAQqLnZtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyt0yFIsg
4 | 713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik9FW3mcqh75sGYwIOBmNdHfsm
5 | Q3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyELAFY5w+iqO1xcLTZO/aOiWXw
6 | BWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6KZ6blxg+regwPEI94MtHbmk47
7 | ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEswuuxkMlWWGhcqYnA9UjbbEZoB
8 | Fb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpyCOyv5z+0+rgR0IxzvhabBpFP
9 | ZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9hsuLaM76mR6W1MbIMe7E93o/
10 | SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEAlXtPCbn+cbKLlxWpA3JS1ePi
11 | /tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMoS7OotF/zOaryQYi4NRi0wktt
12 | K6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efqlqSOHrot3R2dS5dFR+iHKW+z
13 | kU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEpMQorPj/GTSra5qT6KkrtHjjh
14 | hThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEAAaAAMA0GCSqGSIb3DQEBCwUA
15 | A4ICAQBsEBgC2YepuZq/8UqvKMZKVy/etDKXj7BB+QPb+leNiKD7p4LDxHJsZSH8
16 | Ku9uMPeLfiQDn5jA41k5SlGttzvObd65RdEbO3yHpqsg05EGSDDLfaE1k2Al/qmX
17 | /o8roPZF7+2kZthgMAgkcokS54LYqEYTGqOf3J9Ss0yRIZwhaOVebfFIbIOdpw0B
18 | JNMIJPHTMdZrcuRVI+wR1uPLIlEJzBvxTGbTrvPU25WJFtu+EajKqXO0SHdy0yx8
19 | uH4ykRBJRc36+oYo7nZ5D56dh7pZn3+9J64FKAOV0Q3KqMFieGy053ezuhJd70eZ
20 | UozTgfjs3WpMzoYmKETSyl3XZSdInRe+sUlKPruTsKyg69oYxjPlrGfAmmGcCFca
21 | TnZinT18dI92zK7OtOVkmYeYKC1lwuhftVrNMXzZuHOGpS9NNYtc4nDqDMIEOfV3
22 | 6rCdu03WjEgJ+Z67tJs16xOx9du4/EHxS2Ijn9DPfVJvYy0TgzDi1BUpjWx0KTLx
23 | C4OQbEZ/QTWmHVbSch/hcZhzbf7SNh5RpnW4EtmcpDFjIKMfxJmoKeiTf7qnilx0
24 | 7uRvsZFKoDKRDOFiPfgMg5AOtLHziYsd9m0tJjC2GHvFuPjzOtzhnUUjmmvht170
25 | 2aqKakjST4amg7jzLcs871HX0/WjOtt29NpOz140blkKf1bisg==
26 | -----END CERTIFICATE REQUEST-----
27 |
--------------------------------------------------------------------------------
/.docker/tevun/etc/nginx/ssl/server.key:
--------------------------------------------------------------------------------
1 | -----BEGIN RSA PRIVATE KEY-----
2 | MIIJKAIBAAKCAgEAyt0yFIsg713pVnmPVVzK6Y7mbWKVUg7AAi6YxVITJ7D+f4ik
3 | 9FW3mcqh75sGYwIOBmNdHfsmQ3YL/8XrtBzzhW7UeqQqddHdbXSx2baOQsrsbuyE
4 | LAFY5w+iqO1xcLTZO/aOiWXwBWhi+MOTKJK1ZgrbKZ7DGR+/+81OH/enGxd/cy6K
5 | Z6blxg+regwPEI94MtHbmk47ONm2ETfq8C81SgHr/fYkOJDzCZ+L1ev15Oq7aEsw
6 | uuxkMlWWGhcqYnA9UjbbEZoBFb4wgQ26yzp3lIkcH3+qsRLGYux8b+wShY+IlFpy
7 | COyv5z+0+rgR0IxzvhabBpFPZQjKwnlRQXvJCs/3G4Xfsi1MV8AD6+oEjj5sJ9t9
8 | hsuLaM76mR6W1MbIMe7E93o/SuuodQ+yfgYzRVmDNYW5wta+x/8UuxAcwVfKkaEA
9 | lXtPCbn+cbKLlxWpA3JS1ePi/tXMZKcLAkA5cuYN7Zv0wagNjvmSfmB0AxypMzMo
10 | S7OotF/zOaryQYi4NRi0wkttK6UOYF0xBriDah4MF0FpFDum4YEmKnRxl9822efq
11 | lqSOHrot3R2dS5dFR+iHKW+zkU0MIXOlvCgZcm7LGD0pRjhARlI2BjYXqM/RaaEp
12 | MQorPj/GTSra5qT6KkrtHjjhhThRxtNnjoD1cUsKw3jfTFSaOwT8rBjByZkCAwEA
13 | AQKCAgAbZPdoUsllyZbC+LNkYZ19ILD5QIDNjfRb1xMGQmkXyQz1B+zOmeyrNfPc
14 | OWEJabOfJTfj3pByN7SzG3US4333HNpQnW6mbmqqZ0HFFqPrXR/Ecuf+UUhCG5hp
15 | m3bgM2vKbyccYsmg0VHcKfzrU7RvTTP/UNMjx2fThwvvwS+ttuSdF0HVcXJB5sfP
16 | OWWnZNhkdHZlRf81VCED/jsZqCZYEh5eMyj9AoXvXL4zayPPf+tC0DSKaXW2Xlxg
17 | tZQhqup8+a9nlxZia0Z9hu8clo6jXkiP8FuKgfCMV0cOjiCKLLHS5svTbLLsVWwJ
18 | F2ZAdVcD6mWQ43qHOEK5NEzGvQKO14CaOLnVT2yAkMcyNohsEgoDP9oCBGDJQbBH
19 | NmtZfpVjjtuTr9P9TEkU1FcBRo0x6Il/DkzamGbOeFAmgnaGElhJ5c/CAG7whaIf
20 | mUfFOBGPH/wESY3gBOACDofeSh27RrlvbLaPiCGKivDUTBmhBsIuso6XqOKbvtfV
21 | /HhhndpdRVfIj4DdE7gIrLIGN977JMVAXFCNz7KrvAWwcOXrCHCoWpklJ9repq8l
22 | 26ICY8K7VXktzDHQUmhd88ZWR+9ASURsJghUgZUOcMrEGyvci6Y8hpLhHiNVPHuQ
23 | +ps7tpPsXSntBUqWBzhRZh74+nJlOOV6oYykl30JT2JzB6lwiQKCAQEA9ecn8N2z
24 | 20tR2UEiTv/MjVSepQtAAajegvcd1iasvvQKXnh3XLmoZHzH2tTa0lp5RIZpUQPl
25 | lOTwko0lYTBnYblt65AJQ3FTgisNobIpoqE8BFXLm6wggz7CbabjmPGDe173lPGR
26 | sI0YSKYvzrdn4zw8Fh6WULJyZHLi58zJYL3r0WBDiOoxpGaGA1GlmkuIWjhKHaX2
27 | OvF1vOuQDJ2eDyTc5TYFC0NKG76Mvanov5L/yrhNM/umbmp0SPspzHGZobAKUr20
28 | OazFT8S+2TA1OTxWNbiPbSimFoaZbEdqsNACGfVJWO8Sh8iqlt5RmEcSiSvGBj6L
29 | QKprRO9Fsp2GawKCAQEA0zGhRsnux4JTNsdUSYsEJtITMj6eE+nl7CoZ9DAOwC5X
30 | 6/aSpUE4TT+pWNrt9iluXiGL0j89UJ7r/L1OcsiyzGb8ig9NU4zr1NIGTZ0DstHi
31 | HPYINjeiBJEFIy17kOQn+9/I5c4hBUwz6ihwNoEomymVB/EsLJKAML0AudJGKg+Z
32 | /f/qrS40eab5SAiaKgsh0MZnj+vIxyGBydt6r2HGmjfNITVbXIu6IpO+6NXDwM/e
33 | 7v10AAZ3j9+gb1RedLg2ghuIuYU90hmMhtVWsh9nVmaOkMW9/WFgOPYvt/mHH/hR
34 | d4pePZ9kACGmqo/b9sHvHw1YEubtCt1VUiNuFxnJCwKCAQBWnxz0vkRTJY8phsY9
35 | KeK2jm5sGTBs5T2syLwb6ffENFdKvAjgAw6Mh2And/+1ReWd+/MxdLv03UjZdxsJ
36 | x3FDfXx5FH4O4ebW3a+pnAcKoN1xcX+N0O6LDRqUYcue3sTAOs3gC9CUbr91KAWD
37 | Phw8ccWAzTmKJ7IgLFA982ekyoI9eTmRC159WRgwJxy844qerWF+XC4GyXP+HsTZ
38 | jNRW5Vdi7sqMEyIR7+fIEAhLI88zbATWIPmZv6pC4ybwO7wwtsCMMQNBpdjDprzL
39 | 6S12ggikV+U+QKlxGe0FtYqhykRTPJKf32eZqVheWOZJTA/9fgv9ux52oxGycM8O
40 | gmsNAoIBAQC60m5uZnd5uYnPLWkcXYNgq/kbO1UvHHut/FhVMKX7z4MrU0XKNfWO
41 | MECoP5K9bU0aq+Y6KIMe7FapjvT0iSHRu1Cu+HZY8JI2A0xcIAeDijLRl7sP6wrB
42 | q1+2DKgANjRAlWfsEfoX658JBpitPngjOheBnRCMpVQMyUT5HE/BKWf5zwdUB0mY
43 | S+K8nA90HcDeJIS8RcGolbVwUV0oBABhr/cf50lYhqozqCr7YQ33ZGs7Uq3oz8+4
44 | UARmN2YPLl3Znm3GX12em8c6B0LX8vvA7Jw06Rf2Ksup1+3Ce1PTLiEy9A4FyRf3
45 | Hc2HmBbnJAtZlr5QikMqlzzAmmLqwH6dAoIBAC+ryaQGJFsijCSuaDfRp/uy9xnd
46 | DjgMdTwjl5WLBmyudChVMANl8eqCbvVO41CN84yORk03oQ4cx0eKxAZaLaSzgkb3
47 | W0X2nFQe7VJSYMQswCQ+1WfJvEFrIdkEKIa//uQdhqNrgUKSNVhhSTMbNEkDTIWn
48 | ssbv2H9hvUaFt/J/vP9zCKuU5oYvNU7Oi6ZXRYezRn9atlJYanLFoJnHUBRzGms5
49 | K0vhdCPDXQq87z5Yudoh0jLUQF9Nx0GTWeBceQ9n5hZeRUNQWxP4AJThQX9KSPTS
50 | mbL3Kh4XNRmAUJ2N+Njh+3dg91s+JkKvC1wcspLsmLPQe+9AxBSH9y5JE/8=
51 | -----END RSA PRIVATE KEY-----
52 |
--------------------------------------------------------------------------------
/.docker/tevun/etc/nginx/tevun.conf:
--------------------------------------------------------------------------------
1 | access_log /var/log/nginx/access.log;
2 |
3 | #Adjust client timeouts
4 | client_max_body_size 0;
5 | client_body_buffer_size 1k;
6 | client_header_buffer_size 1k;
7 | large_client_header_buffers 1 2k;
8 | client_body_timeout 15s;
9 | client_header_timeout 15s;
10 | keepalive_timeout 15s;
11 | send_timeout 15s;
12 | sendfile on;
13 | tcp_nopush on;
14 | tcp_nodelay on;
15 |
16 | #Adjust output buffers
17 | fastcgi_buffers 256 48k;
18 | fastcgi_buffer_size 48k;
19 | fastcgi_connect_timeout 15s;
20 | fastcgi_send_timeout 15s;
21 | fastcgi_read_timeout 15s;
22 | fastcgi_busy_buffers_size 256k;
23 | fastcgi_max_temp_file_size 0;
24 | reset_timedout_connection on;
25 |
26 | location /ping {
27 | add_header Content-Type text/plain;
28 | auth_basic off;
29 | return 200 'pong';
30 | }
31 |
32 | location ~ ^.*/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
33 | auth_basic "Restricted";
34 | auth_basic_user_file /etc/nginx/.users;
35 |
36 | fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
37 | include fastcgi_params;
38 | fastcgi_param GIT_HTTP_EXPORT_ALL "";
39 | fastcgi_param GIT_PROJECT_ROOT /app/projects;
40 | fastcgi_param PATH_INFO $uri;
41 |
42 | # Forward REMOTE_USER as we want to know when we are authenticated
43 | fastcgi_param REMOTE_USER tevun;
44 | fastcgi_pass unix:/run/fcgi.sock;
45 | }
46 |
47 | location ~ ^/cgi {
48 | auth_basic "Restricted";
49 | auth_basic_user_file /etc/nginx/.users;
50 |
51 | add_header Content-Type text/plain;
52 |
53 | root /app/cgi;
54 | rewrite ^/cgi/(.*) /$1 break;
55 |
56 | include fastcgi_params;
57 |
58 | fastcgi_param QUERY_STRING $query_string;
59 | fastcgi_param REQUEST_METHOD $request_method;
60 | fastcgi_param CONTENT_TYPE $content_type;
61 | fastcgi_param CONTENT_LENGTH $content_length;
62 |
63 | fastcgi_param SCRIPT_NAME $fastcgi_script_name;
64 | fastcgi_param REQUEST_URI $request_uri;
65 | fastcgi_param DOCUMENT_URI $document_uri;
66 | fastcgi_param DOCUMENT_ROOT $document_root;
67 | fastcgi_param SERVER_PROTOCOL $server_protocol;
68 | fastcgi_param HTTPS $https if_not_empty;
69 |
70 | fastcgi_param GATEWAY_INTERFACE CGI/1.1;
71 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
72 |
73 | fastcgi_param REMOTE_ADDR $remote_addr;
74 | fastcgi_param REMOTE_PORT $remote_port;
75 | fastcgi_param SERVER_ADDR $server_addr;
76 | fastcgi_param SERVER_PORT $server_port;
77 | fastcgi_param SERVER_NAME $server_name;
78 |
79 | fastcgi_pass unix:/run/fcgi.sock;
80 | fastcgi_param SCRIPT_FILENAME /app/cgi$fastcgi_script_name;
81 | }
82 |
83 | location / {
84 | try_files $uri $uri/ =404;
85 | }
86 |
--------------------------------------------------------------------------------
/.env.sample:
--------------------------------------------------------------------------------
1 | TEVUN_HOST={TEVUN_HOST}
2 | TEVUN_PORT_HTTP={TEVUN_PORT_HTTP}
3 | TEVUN_PORT_HTTPS={TEVUN_PORT_HTTPS}
4 | TEVUN_PORT_SSH={TEVUN_PORT_SSH}
5 |
6 | TEVUN_USER_ID="{TEVUN_USER_ID}"
7 |
8 | TEVUN_USER_EMAIL="setup@tevun.com"
9 | TEVUN_USER_NAME="Tevun Setup"
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 |
3 | /.env
4 | /.key
5 | /.users
6 | /docker-compose.yml
7 |
8 | /vendor
9 | *.cache
10 |
--------------------------------------------------------------------------------
/.users.sample:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/.users.sample
--------------------------------------------------------------------------------
/PROJECT.md:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | # Tevun ~ WIP
10 |
11 | ### Disclaimer
12 | ----
13 | > No momento não há ainda como fazer os procedimentos abaixo.
14 | >
15 | > Para entender o estado do projeto atualmente clique [aqui](https://github.com/tevun/server#versões-iniciais)
16 | ----
17 |
18 | # O Projeto
19 |
20 | Este projeto é uma API para gerenciamento de domínios destinada à gerenciar múltiplos hosts em contêineres gerenciados por arquivos que seguem o padrão "docker-compose".
21 | Utilizando ele você transforma seu VPS em um ambiente simples e rápido para deploy de aplicações.
22 |
23 | Para publicar uma aplicação basta executar um comando para criação de um `git remote` com um hook `post-receive` configurado para parar e subir seu projeto `docker-compose`.
24 | Com essa estratégia você pode instalar bancos de dados, criar volumes e manipular todo o ambiente remoto do seu servidor apenas com um comando `git push`.
25 |
26 | ## Objetivo do Projeto
27 |
28 | Se você tem trabalhado no seu ambiente de desenvolvimento com Docker deve ter encontrado pelo caminho alguns desafios na hora de publicar sua aplicação no ambiente de homologação, ou mesmo em produção. Costumeiramente deve ter sido preciso publicar sua aplicação em um ambiente não homogêneo ao seu, como servidores de hospedagem, ou mesmo em VPS's onde é tudo instalado diretamente na máquina e é complicado ficar mudando as versões dos serviços. Provavelmente você precisa fazer vários acessos via ssh para poder obter as configurações necessárias.
29 |
30 | O Tevun atua justamente nesse ponto: integrar seu ambiente de desenvolvimento aos seus ambientes remotos. O processo é simples e não há nenhum milagre. Ao criar uma entrada no servidor que tem o Docker, Docker-Compose e Tevun instalados você recebe um `docker-compose.yml` básico e a URL de um repositório remoto para o Git. Quando faz um `git push` para esse **remote** um script _post-receive_, previamente configurado, no repositório se encarrega de fazer checkout do seu código para a pasta do projeto no servidor e parar e subir os containers.
31 |
32 | Sendo assim ao usar o Tevun você passa a ter um gerenciador de sites que cria os domínios e vhosts para você (inclusive com a parte do ssl - https - fornecido pelo Let's Encrypt) de forma automatizada e roda seus projetos através de seus containers. Ao fazer um `git push` ou usar `webhooks` (e incluir as devidas configurações) você pode reconfigurar tudo o que você tinha de infra no seu projeto remoto, replicando o mesmo ambiente que você tinha em desenvolvimento.
33 |
34 | ### Acompanhe
35 | - [Telegram](https://t.me/tevun)
36 | - [Twitter](https://twitter.com/tevunapp)
37 | - [Site](https://tevun.com)
38 |
39 | ## Como isso funciona?
40 |
41 | Você vai instalar este projeto no seu servidor.
42 | Durante a instalação será gerada uma `server key`, guarde-a.
43 | Depois de instalado ele irá disponibilizar para você um conjunto de comandos e endpoints para que você possa adicionar e remover `sites` do seu servidor de forma automatizada.
44 |
45 | A topologia do projeto é semelhante à imagem abaixo.
46 |
47 |
51 |
52 |
53 | Para garantir a identidade do cliente é preciso pareá-lo antes de rodar os primeiros comandos.
54 | Para fazer este processo é preciso informar o `server key`, que será validado para ativação do cliente que fez o pedido como apto a se comunicar com o servidor.
55 |
56 |
60 |
61 |
62 | Para realizar essas configurações você pode usar o CLI para parear com o servidor, e, dai pra frente poderá usar esse servidor para adicionar seus domínios:
63 | ```
64 | $ tevun pair
65 | $ tevun add example.com
66 | ```
67 |
68 | E quando acessar no navegador verá:
69 |
70 |
74 |
75 |
76 | Da mesma forma você pode usar o CLI para remover o domínio
77 | ```
78 | $ tevun rm example.com
79 | ```
80 |
81 | Você pode ver os arquivos que são gerados para esse setup inicial [aqui](https://github.com/tevun/server/tree/master/samples)
82 |
83 | ### O Servidor
84 |
85 | A API Rest para gerenciar o servidor contém os endpoints:
86 |
87 | | METHOD | URL |
88 | |--------|--------------------------------|
89 | | GET | /v1/projects |
90 | | POST | /v1/projects |
91 | | GET | /v1/projects/`` |
92 | | DELETE | /v1/projects/`` |
93 | | PATCH | /v1/projects/``/down |
94 | | PATCH | /v1/projects/``/up |
95 | | PUT | /v1/projects/``/env |
96 | | GET | /v1/projects/``/env |
97 |
98 | E conta com os seguintes comandos:
99 |
100 | | COMMAND | OUTPUT |
101 | |---------------------------|--------------------------------------|
102 | | install `` | generated key |
103 | | info | ``, `` and generated key |
104 | | ls | domains list |
105 | | create `` | docker-compose.yml & git remote |
106 | | destroy `` | docker output |
107 | | start `` | docker output |
108 | | stop `` | docker output |
109 |
110 | ### O Cliente
111 |
112 | O Cliente disponibiliza os seguintes comandos:
113 |
114 | | COMMAND | OUTPUT |
115 | |---------------------------|--------------------------------------|
116 | | pair `` | pair host confirmation |
117 | | unpair `` | hosts list |
118 | | paired | hosts list |
119 | | use `` | selection confirmation |
120 | | ls | domains list |
121 | | add `` | docker-compose.yml & git remote |
122 | | rm `` | docker output |
123 | | up `` | docker output |
124 | | down `` | docker output |
125 |
126 | ### Versões Iniciais
127 |
128 | Nestas versões iniciais ainda não temos vários recursos disponíveis, como a API e o CLI, mas temos um conjunto de comandos que já pode dar uma ideia do que está por vir.
129 |
130 | Como requisitos para rodar o projeto você precisa ter o `docker` e o `docker-compose` instalados.
131 | Caso não tenha você pode ver se o seu sistema é compatível com algum dos nossos instaladores disponíveis.
132 | Dê uma olha [nesta pasta](https://github.com/tevun/server/tree/master/installers) para ver se encontra seu sitema na lista.
133 | Obtenha Mais informações sobre uso do nossos instaladores [aqui](https://github.com/tevun/server#instalação-de-requisitos).
134 |
135 | Para instalar o projeto em suas versões iniciais é preciso fazer os passos abaixo:
136 |
137 | ##### Instalação
138 |
139 | Instale o tevun no seu servidor
140 | ```
141 | $ ssh root@
142 | # mkdir -p /usr/share/tevun
143 | # cd /usr/share/tevun
144 | # git clone https://github.com/tevun/server.git .
145 | # ln -s $(pwd)/tevun.sh /usr/bin/tevun
146 | ```
147 |
148 | Configure as credenciais adequadamente
149 | ```
150 | # tevun password (gere uma senha para usar adiante)
151 | # passwd [opcional] (use para ter uma senha do seu root para usar como SU)
152 | # tevun user {user}
153 | ```
154 |
155 | Reinicie seu servidor e entre com o usuário sem privilégios para fazer o setup do Tevun
156 | ```
157 | # tevun ubuntu/locale [opcional] (use para configurar o locale do Ubuntu)
158 | # reboot
159 | $ ssh {user}@
160 | $ sudo tevun setup {user}
161 | ```
162 |
163 | #### Gerenciando os Domínios
164 |
165 | Para gerencias os domínios você tem os seguintes comandos:
166 |
167 | - `tevun create []`: Add one domain to the list of domains. The template default is `php`, but you can use `html` or add others
168 | - `tevun destroy `: Remove the domain of list of domains
169 | - `tevun start `: Start the domain execution
170 | - `tevun stop `: Stop the domain execution
171 | - `tevun up `: Puts the domain up
172 | - `tevun down `: Puts the domain down
173 | - `tevun live`: Make all sites available
174 | - `tevun die`: Stop all containers
175 |
176 | ##### Configurando o projeto
177 |
178 | ```
179 | $ git remote add deploy ssh://@/projects//repo
180 | $ git fetch deploy +refs/heads/setup:refs/remotes/deploy/setup
181 | $ git branch --no-track setup refs/remotes/deploy/setup
182 | $ git branch --set-upstream-to=deploy/setup setup
183 | $ git merge --no-ff deploy/setup --allow-unrelated-histories
184 | ```
185 |
186 | ### Instalação de Requisitos
187 |
188 | Os comandos de instalação possuem a estrutura abaixo
189 | ```
190 | # tevun requirement [ubuntu,debian,fedora,arch]
191 | ```
192 |
193 | Para instalar no `ubuntu`
194 | ```
195 | # tevun requirement ubuntu
196 | ```
197 |
198 | Para instalar no `ubuntu` o docker `17.12.0~ce-0~ubuntu` e docker-compose `1.18.0`, com a configuração de usuário direcionada para o `heimdall` e para reiniciar ao final do script e corrigir problemas de local a instrução seria como a seguir
199 | ```
200 | # tevun requirement ubuntu heimdall 17.12.0~ce-0~ubuntu 1.18.0 yes yes
201 | ```
202 |
203 | #### Parâmetros
204 |
205 | 1. `` [optional]
206 | O nome do usuário que terá acesso ao servidor.
207 | Pode ser `sysadmin` ou qualquer coisa que você quiser.
208 | O usuário informado deverá ser usado no próximo acesso ao servidor e o usuário `root` perderá acesso ao SSH.
209 | O valor padrão será `tevun`;
210 |
211 | 2. `` [optional]
212 | Versão do docker que você quer instalar.
213 | Você pode usar esse parâmetro para manter homogeneidade entre seus ambientes.
214 | Se você passar `edge` ou não informar a versão mais atual será usada;
215 |
216 | 3. `` [optional]
217 | Versão do docker-compose.
218 | Se você usar `edge` ou não informar a versão mais atual será usada;
219 |
220 | 4. `` [optional]
221 | Controle para reiniciar o sistema.
222 | Suporta `yes` e `no`, seu valor padrão é `yes`;
223 |
224 | 5. `` [optional]
225 | Corrige problemas relacionados à locales nos servidores.
226 | Suporta `yes` e `no`, seu valor padrão é `yes`;
227 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | # Tevun ~ WIP
10 |
11 | Tevun is a set of scripts intended to make life easier for developers and sysadmins in general.
12 | It combines docker, docker-compose and git to automate tasks such as uploading containers, configuring reverse proxy, configuring SSL, and more.
13 | After setting up tevun on your server you can upload an environment that applies your development docker-compose and configures a virtual host for your LetsEncrypt SSL-enabled domain quickly and simply.
14 | Each created project generates a remote git that is already preconfigured to publish the application to the destination directory.
15 | That way we can configure the scripts to publish our changes in our stage or production environments.
16 |
17 | ### Follow
18 | - [Telegram](https://t.me/tevun)
19 | - [Twitter](https://twitter.com/tevunapp)
20 | - [Site](https://tevun.com)
21 |
22 | ## Getting Started
23 |
24 | ### Requirements
25 |
26 | Verify that your server has the following requirements:
27 | - Git (git --version): git version +2.10.x
28 | - Docker (docker -v): Docker version +18.0x.x-ce, build xxxxxxx
29 | - Docker Compose (docker-compose -v): docker-compose version +1.2x.x, build xxxxxxxxx
30 |
31 | ### Download
32 |
33 | Access your server using ssh
34 | ```
35 | $ ssh root@
36 | ```
37 |
38 | Then create the installation dir, clone repository and create the symlink to use command `tevun` in terminal
39 | ```
40 | # mkdir -p /usr/share/tevun
41 | # git clone https://github.com/tevun/server.git /usr/share/tevun
42 | # ln -s $(pwd)/tevun.sh /usr/bin/tevun
43 | ```
44 |
45 | ### Setting up Tevun
46 |
47 | Let's configure Tevun on your server. First, let's check the user settings and permissions, and then let's configure Tevun.
48 |
49 | #### Users and permissions
50 |
51 | > if you already have an user with the necessary permissions to run your containers or this is not relevant to your scenario you can disregard this topic.
52 |
53 | It is important that you avoid using your root user via SSH.
54 | It is recommended that you create an user that is limited in order to be able to access your server via SSH.
55 | Since we are dealing with docker, we need to have a local user with the same UID that the images will use. Usually this UID is the 1000.
56 | To facilitate this operation you can **optionally** use the command below, where is the name you want to assign to the new user.
57 |
58 | ```
59 | # tevun user
60 | ```
61 | * this command will also add the new user to the docker group and sudoers group
62 |
63 | #### Access policy via SSH
64 |
65 | You can use a single Tevun command to configure a less privileged user to access SSH and disable root access by using the command below.
66 |
67 | > Just use it if you know what it's doing!
68 |
69 | ```
70 | # tevun ssh
71 | ```
72 |
73 | #### Tevun setup
74 |
75 | To perform the setup use the following command in the terminal, replacing with the name of the user that will be used to manipulate the containers.
76 | ```
77 | # tevun setup
78 | ```
79 |
80 |
81 |
82 |
83 | After perform this command you can access the your server in port what you choose to see if it works.
84 |
85 |
86 |
87 |
88 | Setup command will create 3 containers:
89 | - nginx-proxy: a ngix instance to make the reverse proxy and allow we up various containers to the same port
90 | - nginx-letsencrypt: a listener to docker socket that run LetsEncrypt bot to VIRTUAL_HOST property of containers environment
91 | - tevun: nginx server configured to run CGI and communicate with docker of host
92 |
93 | ### Using Tevun
94 |
95 | Before start the usage you can edit the .env file to configure the properties of your server.
96 | Open the `.env` file with your favorite editor and change the properties to suit your needs.
97 |
98 | #### Create a new project
99 |
100 | ```
101 | $ tevun create
102 | ```
103 | This command will add a new project in projects dir.
104 | Where is the name of project and can be `php` or `html`. We can add other templates too.
105 | The main idea is to have skeletons to most common structures used.
106 |
107 | Example:
108 | ```
109 | $ tevun create site.com html
110 | ```
111 | In this example tevun will create `site.com` project, initialize a git remote repository, configure post-receive, generate a docker-compose.yml and show the git remote URL in terminal.
112 |
113 |
114 |
115 |
116 | #### Register users
117 |
118 | Once the projects have been created we can make a local clone of them, but for that we need an user with access permission.
119 | To register users in Tevun use the command below:
120 | ```
121 | $ tevun register
122 | ```
123 | This is a short hand to http basic auth and the file with permissions is in file `/etc/nginx/.users` of tevun container.
124 |
125 |
126 |
127 |
128 | #### Destroy a project
129 |
130 | ```
131 | $ tevun destroy
132 | ```
133 | The command destroy will stop your docker-compose project and erase the project dir.
134 | The command will not erase the docker volumes, but is important to be careful with this instruction.
135 |
136 |
137 |
138 |
139 |
140 | #### Configure in an existing project
141 |
142 | We can get the branch setup of project repository to get the files to configure our project to run in Tevun.
143 |
144 | ```
145 | # add the remote to your repo
146 | $ git remote add deploy https://@://repo
147 | # fetch the setup branch
148 | $ git fetch deploy +refs/heads/setup:refs/remotes/deploy/setup
149 | # get setup branch from remote
150 | $ git branch --track setup refs/remotes/deploy/setup
151 | # merge setup branch to your local branch
152 | $ git merge --no-ff deploy/setup --allow-unrelated-histories
153 | ```
154 |
--------------------------------------------------------------------------------
/badge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/badge.png
--------------------------------------------------------------------------------
/cgi/create.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Content-Type: text/plan"
4 | echo ""
5 | echo "create"
6 |
--------------------------------------------------------------------------------
/cgi/destroy.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Content-Type: text/plan"
4 | echo ""
5 | echo "destroy"
6 |
--------------------------------------------------------------------------------
/cgi/ping.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Content-Type: text/plan"
4 | echo ""
5 | echo "pong"
6 |
--------------------------------------------------------------------------------
/commands/compress/do.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | tar -zcvf ${1}.tar.gz ${1}
--------------------------------------------------------------------------------
/commands/compress/undo.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | tar -xvf ${1}
--------------------------------------------------------------------------------
/commands/credential/password.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | wget -nv -q -O ~/~password http://www.passwordrandom.com/query?command=password
4 |
5 | echo "Password generated: $(cat ~/~password)"
6 |
--------------------------------------------------------------------------------
/commands/credential/register.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | __plot "[1/2] Type the username of new user: "
4 | read NEW_USER
5 |
6 | __plot "[2/2] Type the password of new user: "
7 | docker exec -it tevun htpasswd -c /etc/nginx/.users ${NEW_USER}
8 |
9 | __plot "[FINISH] ~> New user '${NEW_USER}' created"
10 |
--------------------------------------------------------------------------------
/commands/credential/ssh.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TEVUN_USER_INSTALL=${2}
4 |
5 | echo "[1/2] ~> Configure '~/.ssh/authorized_keys'"
6 |
7 | mkdir -p /home/${TEVUN_USER_INSTALL}/.ssh/
8 | cp ~/.ssh/authorized_keys /home/${TEVUN_USER_INSTALL}/.ssh/
9 | chmod 755 /home/${TEVUN_USER_INSTALL}/.ssh/authorized_keys
10 | chown -R ${TEVUN_USER_INSTALL}:${TEVUN_USER_INSTALL} /home/${TEVUN_USER_INSTALL}
11 | echo "deploy ALL=(ALL) ALL" > /etc/sudoers.d/deploy
12 |
13 | echo "[2/2] ~> Configure '/etc/ssh/sshd_config'"
14 | TEVUN_USER_ALLOWED=$(grep -c ^AllowUsers.*${TEVUN_USER_INSTALL}: /etc/ssh/sshd_config)
15 | if [[ "$TEVUN_USER_ALLOWED" = '0' ]]; then
16 | printf '\n%s %s\n' 'AllowUsers' ${TEVUN_USER_INSTALL} >> /etc/ssh/sshd_config
17 | fi
18 |
--------------------------------------------------------------------------------
/commands/credential/user.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TEVUN_USER_INSTALL=${2}
4 |
5 | echo "[1/2] ~> Create '${TEVUN_USER_INSTALL}'"
6 | EXISTS=$(grep -c ^${TEVUN_USER_INSTALL}: /etc/passwd)
7 | if [[ "$EXISTS" = '0' ]]; then
8 | useradd -u 1000 --non-unique ${TEVUN_USER_INSTALL}
9 | fi
10 |
11 | echo "[2/2] ~> Add '${TEVUN_USER_INSTALL}' to docker and root groups"
12 | usermod -aG docker ${TEVUN_USER_INSTALL}
13 | usermod -aG root ${TEVUN_USER_INSTALL}
14 |
--------------------------------------------------------------------------------
/commands/database/mysql-export.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | TEVUN_DATABASE=${1}
4 | TEVUN_USER="root"
5 | TABLES="SELECT table_name FROM tables WHERE table_type = 'BASE TABLE' AND table_schema = '${TEVUN_DATABASE}'"
6 |
7 | mysql INFORMATION_SCHEMA\
8 | --skip-column-names\
9 | --batch -e ${TABLES} | xargs mysqldump -u ${TEVUN_USER} -p ${TEVUN_DATABASE} > $(date).sql
10 |
--------------------------------------------------------------------------------
/commands/database/mysql-import.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # docker run -it -v $(pwd):/dump mysql:5.6 bash
4 |
5 | mysql -f -h ${TEVUN_HOST} -u ${TEVUN_USER} -p ${TEVUN_DATABASE} < ${TEVUN_FILE}
--------------------------------------------------------------------------------
/commands/down.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BASE=$(dirname $(dirname $(readlink -f ${0})))
4 | PROJECT=${1}
5 | APP=${BASE}/${PROJECT}/app
6 |
7 | cd ${APP}
8 |
9 | docker-compose down
10 |
--------------------------------------------------------------------------------
/commands/project/create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PROJECT=${2}
4 | SAMPLE=${3}
5 |
6 | SAMPLES=${TEVUN_DIR}/samples
7 | PROJECTS=${TEVUN_DIR}/projects
8 |
9 | REPO=${PROJECTS}/${PROJECT}/repo
10 | APP=${PROJECTS}/${PROJECT}/app
11 |
12 | if [[ ! "${SAMPLE}" ]]; then
13 | SAMPLE="html"
14 | fi
15 |
16 | # CREATE REPO
17 | mkdir -p ${REPO}
18 | __plot "[1/8] Create project repo dir '${REPO}'"
19 | cd ${REPO}
20 | git init --bare > /dev/null
21 | git config --file config http.receivepack true > /dev/null
22 |
23 | # CREATE APP
24 | mkdir -p ${APP} > /dev/null
25 | __plot "[2/8] Create project app dir '${APP}'"
26 | cd ${APP}
27 | git init > /dev/null && git remote add origin ${REPO} > /dev/null
28 | __plot "[3/8] Initialize git master remote"
29 | git commit --allow-empty -m "[init]" > /dev/null && git push origin master > /dev/null
30 |
31 | # CONFIGURE REPO
32 | __plot "[4/8] Configure hooks in repo"
33 | cp -TRv ${SAMPLES}/${SAMPLE}/repo/ ${REPO}/ > /dev/null
34 | find ${REPO}/hooks -type f -exec sed -i "s/{project}/${PROJECT}/g" {} \; > /dev/null
35 | chmod +x ${REPO}/hooks/post-receive > /dev/null
36 |
37 | # CONFIGURE APP
38 | __plot "[5/8] Configure app dir"
39 | cp -TRv ${SAMPLES}/${SAMPLE}/app/ ${APP}/ > /dev/null
40 | find ${APP} -type f -exec sed -i "s/{project}/${PROJECT}/g" {} \; > /dev/null
41 |
42 | # CONFIGURE SAMPLE
43 | __plot "[6/8] Configure sample project '${SAMPLE}'"
44 | bash ${SAMPLES}/${SAMPLE}/configure.sh ${APP} ${PROJECT}
45 |
46 | # PREPARE APP
47 | __plot "[7/8] Create setup branch"
48 | git checkout -b setup > /dev/null
49 | git add --all > /dev/null && git commit --allow-empty -m "Setup" > /dev/null
50 |
51 | # INIT APP
52 | __plot "[8/8] Configure setup branch"
53 | git push origin setup --force > /dev/null
54 | rm -rf ${APP}/.git > /dev/null
55 | rm ${APP}/.tevun-ready > /dev/null
56 |
57 | TEVUN_USER=$(getent passwd "${TEVUN_USER_ID}" | cut -d: -f1)
58 | # INFO
59 | __plot "[REMOTE]"
60 | __plot " ssh://${TEVUN_USER}@${TEVUN_HOST}:${TEVUN_PORT_SSH}/projects/${PROJECT}/repo"
61 | __plot " http://${TEVUN_HOST}:${TEVUN_PORT_HTTP}/${PROJECT}/repo"
62 | __plot " https://${TEVUN_HOST}:${TEVUN_PORT_HTTPS}/${PROJECT}/repo"
63 | echo " "
64 | __plot "[FINISH] ~> Project '${PROJECT}' created"
65 |
66 |
--------------------------------------------------------------------------------
/commands/project/destroy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PROJECT=${2}
4 | PROJECTS=${TEVUN_DIR}/projects
5 |
6 | APP=${PROJECTS}/${PROJECT}/app
7 |
8 | source "${TEVUN_DIR}/tevun-functions.sh"
9 |
10 | if [[ ! -d ${PROJECTS}/${PROJECT} ]]; then
11 | __plot "[FINISH] ~> Project '${PROJECT}' doesn't exists"
12 | exit 0
13 | fi
14 |
15 | __plot "[1/1] Destroy '${PROJECT}' (${PROJECTS}/${PROJECT})? yes/[N]: "
16 | read -r DESTROY
17 |
18 | TEVUN_MESSAGE="The project '${PROJECT}' was not destroyed"
19 | if [[ ${DESTROY} = "yes" ]]; then
20 | cd "${APP}" || exit
21 | if [[ -f "docker-compose.yml" ]]; then
22 | docker-compose down --volumes
23 | docker-compose rm -f -v
24 | fi
25 | rm -rf "${PROJECTS:?}/${PROJECT}"
26 | TEVUN_MESSAGE="Project '${PROJECT}' destroyed"
27 | fi
28 | __plot "[FINISH] ~> ${TEVUN_MESSAGE}"
29 |
--------------------------------------------------------------------------------
/commands/project/projects.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BASE=${1}
4 | PROJECT=${2}
5 |
6 | PROJECTS=${BASE}/projects
7 |
8 | cd ${PROJECTS}
9 | for f in *; do
10 | if [[ ! -d ${f} ]]; then
11 | continue
12 | fi
13 | echo ${f}
14 | done
15 |
--------------------------------------------------------------------------------
/commands/project/pull.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BASE=${1}
4 | PROJECT=${2}
5 |
6 | PROJECTS=${BASE}/projects
7 |
8 | cd ${PROJECTS}
9 | for f in *; do
10 | if [[ ! -d ${f} ]]; then
11 | continue
12 | fi
13 | COMPOSE=${PROJECTS}/${f}/app/docker-compose.yml
14 | if [[ ! -f ${COMPOSE} ]]; then
15 | continue
16 | fi
17 | echo "##### ${f} #####"
18 |
19 | IFS=$'\n'
20 | var_targets=($(grep "image:" ${PROJECTS}/${f}/app/docker-compose.yml))
21 | unset IFS
22 |
23 | var_length=${#var_targets[@]}
24 | for ((i = 0; i != var_length; i++)); do
25 | var_image="${var_targets[i]}"
26 | echo "~> ${var_image}"
27 | var_command=$(echo ${var_image} | sed 's/image\:/docker\ pull/')
28 | /bin/bash -c "${var_command}"
29 | done
30 |
31 | cd ${PROJECTS}/${f}/app
32 | docker-compose down && docker-compose up -d
33 | cd ${PROJECTS}
34 | done
35 |
36 |
--------------------------------------------------------------------------------
/commands/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | cd ${TEVUN_DIR}
4 |
5 | if [[ "${2}" ]]; then
6 | TEVUN_USER_ID=${2}
7 | fi
8 |
9 | __plot "[1/7] Configure git"
10 | git config --global user.email ${TEVUN_USER_EMAIL} >> /dev/null
11 | git config --global user.name ${TEVUN_USER_NAME} >> /dev/null
12 |
13 | __plot "[2/7] Define env properties"
14 | cp .env.sample .env
15 | #TEVUN_HOST={TEVUN_HOST}
16 | #TEVUN_PORT_HTTP={TEVUN_PORT_HTTP}
17 | #TEVUN_PORT_HTTPS={TEVUN_PORT_HTTPS}
18 | #TEVUN_PORT_SSH={TEVUN_PORT_SSH}
19 |
20 | #TEVUN_USER_ID={TEVUN_USER_ID}
21 |
22 | TEVUN_HOST="localhost"
23 | if [[ "${@}" != *"--quiet"* ]]; then
24 | echo -n " Host? (IP or FQDN) [localhost]: "
25 | read TEVUN_HOST
26 | fi
27 | sed -i "s/{TEVUN_HOST}/${TEVUN_HOST}/g" .env
28 |
29 | TEVUN_PORT_HTTP="1080"
30 | if [[ "${@}" != *"--quiet"* ]]; then
31 | echo -n " HTTP port? [1080]: "
32 | read TEVUN_PORT_HTTP
33 | fi
34 | sed -i "s/{TEVUN_PORT_HTTP}/${TEVUN_PORT_HTTP}/g" .env
35 |
36 | TEVUN_PORT_HTTPS="10443"
37 | if [[ "${@}" != *"--quiet"* ]]; then
38 | echo -n " HTTPS port? [10443]: "
39 | read TEVUN_PORT_HTTPS
40 | fi
41 | sed -i "s/{TEVUN_PORT_HTTPS}/${TEVUN_PORT_HTTPS}/g" .env
42 |
43 | TEVUN_PORT_SSH="1022"
44 | if [[ "${@}" != *"--quiet"* ]]; then
45 | echo -n " SSH port? [1022]: "
46 | read TEVUN_PORT_SSH
47 | fi
48 | sed -i "s/{TEVUN_PORT_SSH}/${TEVUN_PORT_SSH}/g" .env
49 |
50 | TEVUN_USER_ID="1000"
51 | if [[ "${@}" != *"--quiet"* ]]; then
52 | echo -n " User ID to be used in project? [1000]: "
53 | read TEVUN_USER_ID
54 | fi
55 | sed -i "s/{TEVUN_USER_ID}/${TEVUN_USER_ID}/g" .env
56 |
57 | chown ${TEVUN_USER_ID}:${TEVUN_USER_ID} ${TEVUN_DIR}/.env
58 |
59 | __plot "[3/7] Create projects dir in '${TEVUN_DIR}/projects'"
60 | if [[ ! -d "${TEVUN_DIR}/projects" ]];then
61 | mkdir -p ${TEVUN_DIR}/projects
62 | fi
63 |
64 | __plot "[4/7] Configure permissions of projects dir to user: '${TEVUN_USER_ID}'"
65 | chmod 755 ${TEVUN_DIR}/projects
66 | chown ${TEVUN_USER_ID}:${TEVUN_USER_ID} ${TEVUN_DIR}/projects
67 |
68 | __plot "[5/7] Create the symlink in '/projects', new '.users' file and 'docker-compose.yml'"
69 | if [[ ! -h /projects ]];then
70 | ln -s ${TEVUN_DIR}/projects /projects
71 | fi
72 | if [[ ! -f ${TEVUN_DIR}/.users ]];then
73 | cp ${TEVUN_DIR}/.users.sample ${TEVUN_DIR}/.users
74 | chown ${TEVUN_USER_ID}:${TEVUN_USER_ID} ${TEVUN_DIR}/.users
75 | fi
76 | if [[ ! -f ${TEVUN_DIR}/docker-compose.yml ]];then
77 | cp ${TEVUN_DIR}/docker-compose.yml.sample ${TEVUN_DIR}/docker-compose.yml
78 | chown ${TEVUN_USER_ID}:${TEVUN_USER_ID} ${TEVUN_DIR}/docker-compose.yml
79 | fi
80 |
81 | __plot "[6/7] Create global docker network"
82 | NETWORK_EXISTS=$(docker network ls -q -f name=reverse-proxy)
83 | if [[ ! "${NETWORK_EXISTS}" ]];then
84 | docker network create --driver bridge reverse-proxy
85 | fi
86 |
87 | __plot "[7/7] Start docker containers"
88 | docker-compose down && docker-compose rm -f && docker-compose up -d
89 |
90 | __plot "[FINISH] ~> Tevun is ready with"
91 | __plot " Your server key is: '${TEVUN_UUID}'"
92 | __plot " Use 'tevun help'"
93 |
--------------------------------------------------------------------------------
/commands/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BASE=$(dirname $(dirname $(readlink -f ${0})))
4 | PROJECT=${1}
5 | APP=${BASE}/${PROJECT}/app
6 |
7 | cd ${APP}
8 |
9 | docker-compose start
10 |
--------------------------------------------------------------------------------
/commands/stop.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BASE=$(dirname $(dirname $(readlink -f ${0})))
4 | PROJECT=${1}
5 | APP=${BASE}/${PROJECT}/app
6 |
7 | cd ${APP}
8 |
9 | docker-compose stop
10 |
--------------------------------------------------------------------------------
/commands/up.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | BASE=$(dirname $(dirname $(readlink -f ${0})))
4 | PROJECT=${1}
5 | APP=${BASE}/${PROJECT}/app
6 |
7 | cd ${APP}
8 |
9 | docker-compose up -d
10 |
--------------------------------------------------------------------------------
/commands/utils/colors.sh:
--------------------------------------------------------------------------------
1 | # Copyright 2013 Manuel Gutierrez
2 | # https://github.com/xr09/rainbow.sh
3 | # Bash helper functions to put colors on your scripts
4 | #
5 | # Usage example:
6 | # green=$(green "Grass is green")
7 | # echo "Coming next: $green"
8 | #
9 |
10 | __RAINBOWPALETTE="1"
11 |
12 | function __color()
13 | {
14 | echo -e " \e[$__RAINBOWPALETTE;$2m$1\e[0m"
15 | }
16 |
17 | function green()
18 | {
19 | echo $(__color "$1" "32")
20 | }
21 |
22 | function red()
23 | {
24 | echo $(__color "$1" "31")
25 | }
26 |
27 | function blue()
28 | {
29 | echo $(__color "$1" "34")
30 | }
31 |
32 | function purple()
33 | {
34 | echo $(__color "$1" "35")
35 | }
36 |
37 | function yellow()
38 | {
39 | echo $(__color "$1" "33")
40 | }
41 |
42 | function cyan()
43 | {
44 | echo $(__color "$1" "36")
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/commands/utils/compose.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # https://gist.github.com/deviantony/2b5078fe1675a5fedabf1de3d1f2652a
3 |
4 | # get latest docker compose released tag
5 | COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
6 |
7 | # Install docker-compose
8 | sh -c "curl -L https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > /usr/bin/docker-compose"
9 | chmod +x /usr/bin/docker-compose
10 | sh -c "curl -L https://raw.githubusercontent.com/docker/compose/${COMPOSE_VERSION}/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose"
11 |
12 | # Output compose version
13 | docker-compose -v
14 |
--------------------------------------------------------------------------------
/commands/utils/lets-encrypt/renew.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | docker exec nginx-letsencrypt /app/force_renew
4 |
--------------------------------------------------------------------------------
/commands/utils/lets-encrypt/status.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | docker exec nginx-letsencrypt /app/cert_status
4 |
--------------------------------------------------------------------------------
/commands/utils/ps.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | docker ps -a --format "table {{.ID}}\t{{.Names}}\t{{.Ports}}\t{{.Status}}"
--------------------------------------------------------------------------------
/commands/utils/ubuntu/locale.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | apt-get install -y language-pack-pt
4 | locale-gen --purge en_US en_US.UTF-8 pt_BR.UTF-8
5 | dpkg-reconfigure locales
6 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "require": {
3 | "triagens/arangodb": "^3.3",
4 | "slim/slim": "^3.0",
5 | "monolog/monolog": "^1.23"
6 | },
7 | "autoload": {
8 | "psr-4": {
9 | "Tevun\\": "api/"
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "637847ea8e6605097dc545fdcce8afac",
8 | "packages": [
9 | {
10 | "name": "container-interop/container-interop",
11 | "version": "1.2.0",
12 | "source": {
13 | "type": "git",
14 | "url": "https://github.com/container-interop/container-interop.git",
15 | "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8"
16 | },
17 | "dist": {
18 | "type": "zip",
19 | "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8",
20 | "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8",
21 | "shasum": ""
22 | },
23 | "require": {
24 | "psr/container": "^1.0"
25 | },
26 | "type": "library",
27 | "autoload": {
28 | "psr-4": {
29 | "Interop\\Container\\": "src/Interop/Container/"
30 | }
31 | },
32 | "notification-url": "https://packagist.org/downloads/",
33 | "license": [
34 | "MIT"
35 | ],
36 | "description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
37 | "homepage": "https://github.com/container-interop/container-interop",
38 | "time": "2017-02-14T19:40:03+00:00"
39 | },
40 | {
41 | "name": "monolog/monolog",
42 | "version": "1.23.0",
43 | "source": {
44 | "type": "git",
45 | "url": "https://github.com/Seldaek/monolog.git",
46 | "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4"
47 | },
48 | "dist": {
49 | "type": "zip",
50 | "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
51 | "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4",
52 | "shasum": ""
53 | },
54 | "require": {
55 | "php": ">=5.3.0",
56 | "psr/log": "~1.0"
57 | },
58 | "provide": {
59 | "psr/log-implementation": "1.0.0"
60 | },
61 | "require-dev": {
62 | "aws/aws-sdk-php": "^2.4.9 || ^3.0",
63 | "doctrine/couchdb": "~1.0@dev",
64 | "graylog2/gelf-php": "~1.0",
65 | "jakub-onderka/php-parallel-lint": "0.9",
66 | "php-amqplib/php-amqplib": "~2.4",
67 | "php-console/php-console": "^3.1.3",
68 | "phpunit/phpunit": "~4.5",
69 | "phpunit/phpunit-mock-objects": "2.3.0",
70 | "ruflin/elastica": ">=0.90 <3.0",
71 | "sentry/sentry": "^0.13",
72 | "swiftmailer/swiftmailer": "^5.3|^6.0"
73 | },
74 | "suggest": {
75 | "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
76 | "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
77 | "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
78 | "ext-mongo": "Allow sending log messages to a MongoDB server",
79 | "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
80 | "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
81 | "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
82 | "php-console/php-console": "Allow sending log messages to Google Chrome",
83 | "rollbar/rollbar": "Allow sending log messages to Rollbar",
84 | "ruflin/elastica": "Allow sending log messages to an Elastic Search server",
85 | "sentry/sentry": "Allow sending log messages to a Sentry server"
86 | },
87 | "type": "library",
88 | "extra": {
89 | "branch-alias": {
90 | "dev-master": "2.0.x-dev"
91 | }
92 | },
93 | "autoload": {
94 | "psr-4": {
95 | "Monolog\\": "src/Monolog"
96 | }
97 | },
98 | "notification-url": "https://packagist.org/downloads/",
99 | "license": [
100 | "MIT"
101 | ],
102 | "authors": [
103 | {
104 | "name": "Jordi Boggiano",
105 | "email": "j.boggiano@seld.be",
106 | "homepage": "http://seld.be"
107 | }
108 | ],
109 | "description": "Sends your logs to files, sockets, inboxes, databases and various web services",
110 | "homepage": "http://github.com/Seldaek/monolog",
111 | "keywords": [
112 | "log",
113 | "logging",
114 | "psr-3"
115 | ],
116 | "time": "2017-06-19T01:22:40+00:00"
117 | },
118 | {
119 | "name": "nikic/fast-route",
120 | "version": "v1.3.0",
121 | "source": {
122 | "type": "git",
123 | "url": "https://github.com/nikic/FastRoute.git",
124 | "reference": "181d480e08d9476e61381e04a71b34dc0432e812"
125 | },
126 | "dist": {
127 | "type": "zip",
128 | "url": "https://api.github.com/repos/nikic/FastRoute/zipball/181d480e08d9476e61381e04a71b34dc0432e812",
129 | "reference": "181d480e08d9476e61381e04a71b34dc0432e812",
130 | "shasum": ""
131 | },
132 | "require": {
133 | "php": ">=5.4.0"
134 | },
135 | "require-dev": {
136 | "phpunit/phpunit": "^4.8.35|~5.7"
137 | },
138 | "type": "library",
139 | "autoload": {
140 | "psr-4": {
141 | "FastRoute\\": "src/"
142 | },
143 | "files": [
144 | "src/functions.php"
145 | ]
146 | },
147 | "notification-url": "https://packagist.org/downloads/",
148 | "license": [
149 | "BSD-3-Clause"
150 | ],
151 | "authors": [
152 | {
153 | "name": "Nikita Popov",
154 | "email": "nikic@php.net"
155 | }
156 | ],
157 | "description": "Fast request router for PHP",
158 | "keywords": [
159 | "router",
160 | "routing"
161 | ],
162 | "time": "2018-02-13T20:26:39+00:00"
163 | },
164 | {
165 | "name": "pimple/pimple",
166 | "version": "v3.2.3",
167 | "source": {
168 | "type": "git",
169 | "url": "https://github.com/silexphp/Pimple.git",
170 | "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32"
171 | },
172 | "dist": {
173 | "type": "zip",
174 | "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32",
175 | "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32",
176 | "shasum": ""
177 | },
178 | "require": {
179 | "php": ">=5.3.0",
180 | "psr/container": "^1.0"
181 | },
182 | "require-dev": {
183 | "symfony/phpunit-bridge": "^3.2"
184 | },
185 | "type": "library",
186 | "extra": {
187 | "branch-alias": {
188 | "dev-master": "3.2.x-dev"
189 | }
190 | },
191 | "autoload": {
192 | "psr-0": {
193 | "Pimple": "src/"
194 | }
195 | },
196 | "notification-url": "https://packagist.org/downloads/",
197 | "license": [
198 | "MIT"
199 | ],
200 | "authors": [
201 | {
202 | "name": "Fabien Potencier",
203 | "email": "fabien@symfony.com"
204 | }
205 | ],
206 | "description": "Pimple, a simple Dependency Injection Container",
207 | "homepage": "http://pimple.sensiolabs.org",
208 | "keywords": [
209 | "container",
210 | "dependency injection"
211 | ],
212 | "time": "2018-01-21T07:42:36+00:00"
213 | },
214 | {
215 | "name": "psr/container",
216 | "version": "1.0.0",
217 | "source": {
218 | "type": "git",
219 | "url": "https://github.com/php-fig/container.git",
220 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
221 | },
222 | "dist": {
223 | "type": "zip",
224 | "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
225 | "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
226 | "shasum": ""
227 | },
228 | "require": {
229 | "php": ">=5.3.0"
230 | },
231 | "type": "library",
232 | "extra": {
233 | "branch-alias": {
234 | "dev-master": "1.0.x-dev"
235 | }
236 | },
237 | "autoload": {
238 | "psr-4": {
239 | "Psr\\Container\\": "src/"
240 | }
241 | },
242 | "notification-url": "https://packagist.org/downloads/",
243 | "license": [
244 | "MIT"
245 | ],
246 | "authors": [
247 | {
248 | "name": "PHP-FIG",
249 | "homepage": "http://www.php-fig.org/"
250 | }
251 | ],
252 | "description": "Common Container Interface (PHP FIG PSR-11)",
253 | "homepage": "https://github.com/php-fig/container",
254 | "keywords": [
255 | "PSR-11",
256 | "container",
257 | "container-interface",
258 | "container-interop",
259 | "psr"
260 | ],
261 | "time": "2017-02-14T16:28:37+00:00"
262 | },
263 | {
264 | "name": "psr/http-message",
265 | "version": "1.0.1",
266 | "source": {
267 | "type": "git",
268 | "url": "https://github.com/php-fig/http-message.git",
269 | "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
270 | },
271 | "dist": {
272 | "type": "zip",
273 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
274 | "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
275 | "shasum": ""
276 | },
277 | "require": {
278 | "php": ">=5.3.0"
279 | },
280 | "type": "library",
281 | "extra": {
282 | "branch-alias": {
283 | "dev-master": "1.0.x-dev"
284 | }
285 | },
286 | "autoload": {
287 | "psr-4": {
288 | "Psr\\Http\\Message\\": "src/"
289 | }
290 | },
291 | "notification-url": "https://packagist.org/downloads/",
292 | "license": [
293 | "MIT"
294 | ],
295 | "authors": [
296 | {
297 | "name": "PHP-FIG",
298 | "homepage": "http://www.php-fig.org/"
299 | }
300 | ],
301 | "description": "Common interface for HTTP messages",
302 | "homepage": "https://github.com/php-fig/http-message",
303 | "keywords": [
304 | "http",
305 | "http-message",
306 | "psr",
307 | "psr-7",
308 | "request",
309 | "response"
310 | ],
311 | "time": "2016-08-06T14:39:51+00:00"
312 | },
313 | {
314 | "name": "psr/log",
315 | "version": "1.0.2",
316 | "source": {
317 | "type": "git",
318 | "url": "https://github.com/php-fig/log.git",
319 | "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
320 | },
321 | "dist": {
322 | "type": "zip",
323 | "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
324 | "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
325 | "shasum": ""
326 | },
327 | "require": {
328 | "php": ">=5.3.0"
329 | },
330 | "type": "library",
331 | "extra": {
332 | "branch-alias": {
333 | "dev-master": "1.0.x-dev"
334 | }
335 | },
336 | "autoload": {
337 | "psr-4": {
338 | "Psr\\Log\\": "Psr/Log/"
339 | }
340 | },
341 | "notification-url": "https://packagist.org/downloads/",
342 | "license": [
343 | "MIT"
344 | ],
345 | "authors": [
346 | {
347 | "name": "PHP-FIG",
348 | "homepage": "http://www.php-fig.org/"
349 | }
350 | ],
351 | "description": "Common interface for logging libraries",
352 | "homepage": "https://github.com/php-fig/log",
353 | "keywords": [
354 | "log",
355 | "psr",
356 | "psr-3"
357 | ],
358 | "time": "2016-10-10T12:19:37+00:00"
359 | },
360 | {
361 | "name": "slim/slim",
362 | "version": "3.10.0",
363 | "source": {
364 | "type": "git",
365 | "url": "https://github.com/slimphp/Slim.git",
366 | "reference": "d8aabeacc3688b25e2f2dd2db91df91ec6fdd748"
367 | },
368 | "dist": {
369 | "type": "zip",
370 | "url": "https://api.github.com/repos/slimphp/Slim/zipball/d8aabeacc3688b25e2f2dd2db91df91ec6fdd748",
371 | "reference": "d8aabeacc3688b25e2f2dd2db91df91ec6fdd748",
372 | "shasum": ""
373 | },
374 | "require": {
375 | "container-interop/container-interop": "^1.2",
376 | "nikic/fast-route": "^1.0",
377 | "php": ">=5.5.0",
378 | "pimple/pimple": "^3.0",
379 | "psr/container": "^1.0",
380 | "psr/http-message": "^1.0"
381 | },
382 | "provide": {
383 | "psr/http-message-implementation": "1.0"
384 | },
385 | "require-dev": {
386 | "phpunit/phpunit": "^4.0",
387 | "squizlabs/php_codesniffer": "^2.5"
388 | },
389 | "type": "library",
390 | "autoload": {
391 | "psr-4": {
392 | "Slim\\": "Slim"
393 | }
394 | },
395 | "notification-url": "https://packagist.org/downloads/",
396 | "license": [
397 | "MIT"
398 | ],
399 | "authors": [
400 | {
401 | "name": "Rob Allen",
402 | "email": "rob@akrabat.com",
403 | "homepage": "http://akrabat.com"
404 | },
405 | {
406 | "name": "Josh Lockhart",
407 | "email": "hello@joshlockhart.com",
408 | "homepage": "https://joshlockhart.com"
409 | },
410 | {
411 | "name": "Gabriel Manricks",
412 | "email": "gmanricks@me.com",
413 | "homepage": "http://gabrielmanricks.com"
414 | },
415 | {
416 | "name": "Andrew Smith",
417 | "email": "a.smith@silentworks.co.uk",
418 | "homepage": "http://silentworks.co.uk"
419 | }
420 | ],
421 | "description": "Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs",
422 | "homepage": "https://slimframework.com",
423 | "keywords": [
424 | "api",
425 | "framework",
426 | "micro",
427 | "router"
428 | ],
429 | "time": "2018-04-19T19:29:08+00:00"
430 | },
431 | {
432 | "name": "triagens/arangodb",
433 | "version": "v3.3.2",
434 | "source": {
435 | "type": "git",
436 | "url": "https://github.com/arangodb/arangodb-php.git",
437 | "reference": "15829590ba3fa2b163c6b496c83e35016a886d52"
438 | },
439 | "dist": {
440 | "type": "zip",
441 | "url": "https://api.github.com/repos/arangodb/arangodb-php/zipball/15829590ba3fa2b163c6b496c83e35016a886d52",
442 | "reference": "15829590ba3fa2b163c6b496c83e35016a886d52",
443 | "shasum": ""
444 | },
445 | "require": {
446 | "php": ">=5.6.0"
447 | },
448 | "type": "library",
449 | "autoload": {
450 | "psr-0": {
451 | "ArangoDBClient": "lib/"
452 | }
453 | },
454 | "notification-url": "https://packagist.org/downloads/",
455 | "license": [
456 | "Apache-2.0"
457 | ],
458 | "authors": [
459 | {
460 | "name": "Jan Steemann",
461 | "homepage": "https://github.com/arangodb/arangodb-php",
462 | "role": "Developer"
463 | },
464 | {
465 | "name": "Frank Mayer",
466 | "homepage": "https://github.com/arangodb/arangodb-php",
467 | "role": "Developer"
468 | },
469 | {
470 | "name": "Contributors",
471 | "homepage": "https://github.com/arangodb/arangodb-php/graphs/contributors"
472 | }
473 | ],
474 | "description": "ArangoDB PHP client",
475 | "homepage": "https://github.com/arangodb/arangodb-php",
476 | "keywords": [
477 | "Arango",
478 | "ArangoDb",
479 | "database",
480 | "distributed",
481 | "document store",
482 | "graph database",
483 | "multi-model",
484 | "nosql"
485 | ],
486 | "time": "2018-02-18T15:01:16+00:00"
487 | }
488 | ],
489 | "packages-dev": [],
490 | "aliases": [],
491 | "minimum-stability": "stable",
492 | "stability-flags": [],
493 | "prefer-stable": false,
494 | "prefer-lowest": false,
495 | "platform": [],
496 | "platform-dev": []
497 | }
498 |
--------------------------------------------------------------------------------
/docker-compose.yml.sample:
--------------------------------------------------------------------------------
1 | version: '3.7'
2 |
3 | #networks
4 | networks:
5 | #network reverse-proxy
6 | reverse-proxy:
7 | external: true
8 | name: reverse-proxy
9 |
10 | #services
11 | services:
12 |
13 | #service nginx-proxy
14 | nginx-proxy:
15 | image: jwilder/nginx-proxy
16 | container_name: nginx-proxy
17 | restart: unless-stopped
18 | networks:
19 | - reverse-proxy
20 | volumes:
21 | - $HOME/certs:/etc/nginx/certs:ro
22 | - /etc/nginx/vhost.d:/etc/nginx/vhost.d
23 | - /usr/share/nginx/html:/usr/share/nginx/html
24 | - /var/run/docker.sock:/tmp/docker.sock:ro
25 | - .docker/nginx-proxy/etc/nginx/conf.d/server_tokens.conf:/etc/nginx/conf.d/server_tokens.conf:ro
26 | - .docker/nginx-proxy/etc/nginx/conf.d/client_max_body_size.conf:/etc/nginx/conf.d/client_max_body_size.conf:ro
27 | - .docker/nginx-proxy/etc/nginx/conf.d/timeout.conf:/etc/nginx/conf.d/timeout.conf:ro
28 | - .docker/nginx-proxy/etc/nginx/vhost.d/default_location:/etc/nginx/vhost.d/default_location:ro
29 | ports:
30 | - 80:80
31 | - 443:443
32 |
33 | #service nginx-letsencrypt
34 | nginx-letsencrypt:
35 | image: jrcs/letsencrypt-nginx-proxy-companion
36 | container_name: nginx-letsencrypt
37 | restart: unless-stopped
38 | depends_on:
39 | - nginx-proxy
40 | networks:
41 | - reverse-proxy
42 | volumes:
43 | - $HOME/certs:/etc/nginx/certs:rw
44 | - /etc/nginx/vhost.d:/etc/nginx/vhost.d
45 | - /usr/share/nginx/html:/usr/share/nginx/html
46 | - /var/run/docker.sock:/var/run/docker.sock:ro
47 | environment:
48 | - NGINX_PROXY_CONTAINER=nginx-proxy
49 |
50 | tevun:
51 | container_name: tevun
52 | image: tevun/server:1.0
53 | networks:
54 | - reverse-proxy
55 | restart: unless-stopped
56 | privileged: true
57 | volumes:
58 | - .:/app
59 | - .users:/etc/nginx/.users
60 | - /var/run/docker.sock:/var/run/docker.sock:ro
61 | # - .docker/tevun/etc/nginx/local.tevun.com.crt:/etc/nginx/local.tevun.com.crt
62 | # - .docker/tevun/etc/nginx/local.tevun.com.key:/etc/nginx/local.tevun.com.key
63 | # ports:
64 | # - ${TEVUN_PORT_HTTP}:80
65 | # - ${TEVUN_PORT_HTTPS}:443
66 |
--------------------------------------------------------------------------------
/images/output-create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/output-create.png
--------------------------------------------------------------------------------
/images/output-destroy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/output-destroy.png
--------------------------------------------------------------------------------
/images/output-register.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/output-register.png
--------------------------------------------------------------------------------
/images/output-setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/output-setup.png
--------------------------------------------------------------------------------
/images/pair.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/pair.jpg
--------------------------------------------------------------------------------
/images/setup.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/setup.png
--------------------------------------------------------------------------------
/images/topology.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/topology.jpg
--------------------------------------------------------------------------------
/images/works.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/images/works.png
--------------------------------------------------------------------------------
/installers/ubuntu.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | __plot "[1/8] ~> Clear docker"
4 | apt-get remove docker docker-engine docker.io containerd runc
5 |
6 | __plot "[2/8] ~> Install dependencies to install docker"
7 | apt-get install -y \
8 | apt-transport-https \
9 | ca-certificates \
10 | curl \
11 | gnupg-agent \
12 | software-properties-common
13 |
14 | __plot "[3/8] ~> Add key of docker repository"
15 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
16 | apt-key fingerprint 0EBFCD88
17 |
18 | __plot "[4/8] ~> Add docker repository to system"
19 | add-apt-repository \
20 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
21 | $(lsb_release -cs) \
22 | stable"
23 |
24 | __plot "[5/8] ~> Update system repositories sources"
25 | apt-get update
26 |
27 | __plot "[6/8] ~> Install docker"
28 | apt-get install -y docker-ce docker-ce-cli containerd.io
29 | apt-get autoremove -y
30 |
31 | __plot "[7/8] ~> Install docker-compose"
32 | INSTALL_DOCKER_COMPOSE=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
33 | sh -c "curl -L https://github.com/docker/compose/releases/download/${INSTALL_DOCKER_COMPOSE}/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose"
34 | chmod +x /usr/local/bin/docker-compose
35 | sh -c "curl -L https://raw.githubusercontent.com/docker/compose/${INSTALL_DOCKER_COMPOSE}/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose"
36 |
37 | __plot '[8/8] ~> Enable docker on system'
38 | systemctl enable docker
39 |
40 | DOCKER_INSTALLED=$(docker -v)
41 | DOCKER_COMPOSE_INSTALLED=$(docker-compose -v)
42 | __plot "[done] ~> docker -v: $DOCKER_INSTALLED ~> docker-compose -v: $DOCKER_COMPOSE_INSTALLED"
43 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tevun/server/0f557f62ba4c37ccaf75f048fb571e1e37f98a99/logo.png
--------------------------------------------------------------------------------
/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
22 |
24 |
26 |
30 |
34 |
38 |
42 |
43 |
50 |
57 |
64 |
75 |
76 |
98 |
107 |
108 |
110 |
111 |
113 | image/svg+xml
114 |
116 |
117 |
118 |
119 |
120 |
126 |
135 |
136 |
142 |
151 |
152 |
153 |
--------------------------------------------------------------------------------
/projects/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !index.html
3 | !.gitignore
--------------------------------------------------------------------------------
/projects/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Tevun
4 |
26 |
27 |
28 |
29 |
30 | ____ ____
31 | .___________. ._______.\ \ / /.__ __. .__ __.
32 | | | | ____| \ \ / / | | | | | \ | |
33 | `---| |----` | |__ \ \ / / | | | | | \| |
34 | | | | __| \ \/ / | | | | | . ` |
35 | | | | |____ \ / | `--' | | |\ |
36 | |__| |_______| \ / \______/ |__| \__|
37 | \__/
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/samples/html/app/.env.stage:
--------------------------------------------------------------------------------
1 | COMPOSE_PROJECT_NAME={project}
2 |
--------------------------------------------------------------------------------
/samples/html/app/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | image: docker:git
2 |
3 | before_script:
4 | - mkdir -p ~/.ssh
5 | - echo "${DEPLOY_SERVER_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
6 | - chmod 600 ~/.ssh/id_rsa
7 | - eval "$(ssh-agent -s)"
8 | - ssh-add ~/.ssh/id_rsa
9 | - echo ${DEPLOY_HOST}
10 | - ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
11 |
12 | deploy:
13 | only:
14 | - master
15 | script:
16 | - echo "Deploy to ${DEPLOY_REMOTE}"
17 | - git remote add deploy ${DEPLOY_REMOTE}
18 | - git push deploy master --force
19 |
--------------------------------------------------------------------------------
/samples/html/app/.tevun/hooks/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # cd ${1}
4 |
5 | echo " ~> [hooks\install.sh] on [${1}, ${2}]"
6 |
--------------------------------------------------------------------------------
/samples/html/app/.tevun/hooks/post-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\post-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ -f "docker-compose.yml" ]]; then
8 | docker-compose rm
9 | docker-compose up -d
10 | fi
--------------------------------------------------------------------------------
/samples/html/app/.tevun/hooks/pre-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\pre-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ "$(docker ps -q -f name=${2}-app)" ]]; then
8 | docker-compose down
9 | fi
10 |
11 | # rm -rf ./*
12 |
--------------------------------------------------------------------------------
/samples/html/app/.tevun/hooks/setup.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\setup.sh] on [${1}, ${2}]"
6 |
7 | cp .env.stage .env
8 | cp docker-compose.yml.stage docker-compose.yml
9 |
--------------------------------------------------------------------------------
/samples/html/app/docker-compose.yml.stage:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | networks:
4 | reverse-proxy:
5 | external:
6 | name: reverse-proxy
7 |
8 | services:
9 | {project}-app:
10 | image: webdevops/php-apache:7.3
11 | # build:
12 | # dockerfile: ./.docker/app/Dockerfile
13 | # context: .
14 | container_name: {project}-app
15 | restart: always
16 | networks:
17 | - reverse-proxy
18 | volumes:
19 | - .:/var/www/app
20 | environment:
21 | - VIRTUAL_HOST={project}
22 | - WEB_DOCUMENT_ROOT=/var/www/app/public
23 | # - LETSENCRYPT_EMAIL=certificate@{project}
24 | # - LETSENCRYPT_HOST={project}
25 | # - PHP_DEBUGGER="xdebug"
26 | # export XDEBUG_REMOTE_HOST=$(ifconfig wlan0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
27 | # - XDEBUG_REMOTE_HOST=${XDEBUG_REMOTE_HOST}
28 | # - XDEBUG_REMOTE_AUTOSTART=1
29 | # expose:
30 | # - 9000
31 |
32 |
--------------------------------------------------------------------------------
/samples/html/app/public/index.html:
--------------------------------------------------------------------------------
1 | Your domain {project} is working!
2 |
--------------------------------------------------------------------------------
/samples/html/configure.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | APP_DIR=${1}
4 |
5 | #cp ${APP_DIR}/.env.stage ${APP_DIR}/.env
6 | #cp ${APP_DIR}/docker-compose.yml.stage ${APP_DIR}/docker-compose.yml
7 |
--------------------------------------------------------------------------------
/samples/html/repo/hooks/post-receive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR_NAME=$(dirname $(readlink -f ${0}))
4 | BASE=$(dirname $(readlink -f "${DIR_NAME}/../.."))
5 | PROJECT="{project}"
6 | APP="${BASE}/${PROJECT}/app"
7 | BRANCH="master"
8 |
9 | function __plot
10 | {
11 | printf "\033[0;32m${1}\033[0m \n"
12 | }
13 |
14 | cd ${APP}
15 |
16 | # hook pre-checkout
17 | __plot "[1/5] Hook 'pre-checkout'"
18 | if [[ -f ".tevun/hooks/pre-checkout.sh" ]]; then
19 | bash .tevun/hooks/pre-checkout.sh ${APP} ${PROJECT}
20 | fi
21 |
22 | TEVUN_IS_READY="yes"
23 | READY=".tevun-ready"
24 | if [[ ! -f ${READY} ]]; then
25 | TEVUN_IS_READY="no"
26 | fi
27 |
28 | # hook setup
29 | __plot "[2/5] Hook 'setup' (is ready: ${TEVUN_IS_READY})"
30 | if [[ -f ".tevun/hooks/setup.sh" ]]; then
31 | if [[ ${TEVUN_IS_READY} = "no" ]]; then
32 | bash .tevun/hooks/setup.sh ${APP} ${PROJECT}
33 | touch ${READY}
34 | fi
35 | fi
36 |
37 | cd $(dirname ${DIR_NAME})
38 |
39 | __plot "[3/5] Checkout"
40 | GIT_WORK_TREE="${APP}" git checkout -f ${BRANCH}
41 |
42 | cd ${APP}
43 |
44 | # hook post-checkout
45 | __plot "[4/5] Hook post-checkout"
46 | if [[ -f ".tevun/hooks/post-checkout.sh" ]]; then
47 | bash .tevun/hooks/post-checkout.sh ${APP} ${PROJECT}
48 | fi
49 |
50 | # hook install
51 | __plot "[5/5] Hook 'install'"
52 | if [[ -f ".tevun/hooks/install.sh" ]]; then
53 | bash .tevun/hooks/install.sh ${APP} ${PROJECT}
54 | fi
55 |
--------------------------------------------------------------------------------
/samples/laravel/app/.env.stage:
--------------------------------------------------------------------------------
1 | COMPOSE_PROJECT_NAME={project}
2 |
3 | APP_NAME=Laravel
4 | APP_ENV=local
5 | APP_KEY=
6 | APP_DEBUG=true
7 | APP_URL=http://localhost
8 |
9 | MYSQL_ROOT_PASSWORD={root}
10 |
11 | LOG_CHANNEL=stack
12 | LOG_LEVEL=debug
13 |
14 | DB_CONNECTION=mysql
15 | DB_HOST={alias}-mysql
16 | DB_PORT={port}
17 | DB_DATABASE={database}
18 | DB_USERNAME={user}
19 | DB_PASSWORD={password}
20 |
21 | BROADCAST_DRIVER=log
22 | CACHE_DRIVER=file
23 | QUEUE_CONNECTION=sync
24 | SESSION_DRIVER=file
25 | SESSION_LIFETIME=120
26 |
27 | MEMCACHED_HOST=127.0.0.1
28 |
29 | REDIS_HOST=127.0.0.1
30 | REDIS_PASSWORD=null
31 | REDIS_PORT=6379
32 |
33 | MAIL_MAILER=smtp
34 | MAIL_HOST=mailhog
35 | MAIL_PORT=1025
36 | MAIL_USERNAME=null
37 | MAIL_PASSWORD=null
38 | MAIL_ENCRYPTION=null
39 | MAIL_FROM_ADDRESS=null
40 | MAIL_FROM_NAME="${APP_NAME}"
41 |
42 | AWS_ACCESS_KEY_ID=
43 | AWS_SECRET_ACCESS_KEY=
44 | AWS_DEFAULT_REGION=us-east-1
45 | AWS_BUCKET=
46 |
47 | PUSHER_APP_ID=
48 | PUSHER_APP_KEY=
49 | PUSHER_APP_SECRET=
50 | PUSHER_APP_CLUSTER=mt1
51 |
52 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
53 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
54 |
--------------------------------------------------------------------------------
/samples/laravel/app/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | image: docker:git
2 |
3 | before_script:
4 | - mkdir -p ~/.ssh
5 | - echo "${DEPLOY_SERVER_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
6 | - chmod 600 ~/.ssh/id_rsa
7 | - eval "$(ssh-agent -s)"
8 | - ssh-add ~/.ssh/id_rsa
9 | - echo ${DEPLOY_HOST}
10 | - ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
11 |
12 | deploy:
13 | only:
14 | - master
15 | script:
16 | - echo "Deploy to ${DEPLOY_REMOTE}"
17 | - git remote add deploy ${DEPLOY_REMOTE}
18 | - git push deploy master --force
19 |
--------------------------------------------------------------------------------
/samples/laravel/app/.tevun/hooks/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo " ~> [hooks\install.sh] on [${1}, ${2}]"
4 |
5 | cd "${1}" || exit
6 |
7 | docker exec "{alias}-nginx" bash -c "su -c \"composer install --no-interaction --optimize-autoloader --no-progress\" application"
8 |
9 | if [[ -f ".tevun-ready" ]]; then
10 | docker exec "{alias}-nginx" bash -c "php artisan migrate --force"
11 | fi
12 |
--------------------------------------------------------------------------------
/samples/laravel/app/.tevun/hooks/post-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd "${1}" || exit
4 |
5 | echo " ~> [hooks\post-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ -f "docker-compose.yml" ]]; then
8 | docker-compose rm
9 | docker-compose up -d
10 | fi
11 |
--------------------------------------------------------------------------------
/samples/laravel/app/.tevun/hooks/pre-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd "${1}" || exit
4 |
5 | echo " ~> [hooks\pre-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ "$(docker ps -q -f name={alias}-nginx)" ]]; then
8 | docker-compose down
9 | fi
10 |
--------------------------------------------------------------------------------
/samples/laravel/app/.tevun/hooks/setup.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd "${1}" || exit
4 |
5 | echo " ~> [hooks\setup.sh] on [${1}, ${2}]"
6 |
7 | docker exec "{alias}-nginx" php artisan key:generate
8 |
--------------------------------------------------------------------------------
/samples/laravel/app/docker-compose.yml.stage:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | networks:
4 | reverse-proxy:
5 | external:
6 | name: reverse-proxy
7 | internal:
8 | driver: bridge
9 |
10 | volumes:
11 | {alias}-mysql_data:
12 | driver: local
13 |
14 | services:
15 | {alias}-mysql:
16 | image: mysql:5.7
17 | container_name: ${DB_HOST}
18 | restart: always
19 | networks:
20 | - internal
21 | volumes:
22 | - {alias}-mysql_data:/var/lib/mysql
23 | - .:/var/www/app
24 | working_dir: /var/www/app
25 | environment:
26 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
27 | - MYSQL_DATABASE=${DB_DATABASE}
28 | - MYSQL_USER=${DB_USERNAME}
29 | - MYSQL_PASSWORD=${DB_PASSWORD}
30 |
31 | {alias}-nginx:
32 | image: webdevops/php-nginx:8.0
33 | container_name: {alias}-nginx
34 | restart: always
35 | networks:
36 | - reverse-proxy
37 | - internal
38 | volumes:
39 | - .:/var/www/app
40 | working_dir: /var/www/app
41 | depends_on:
42 | - {alias}-mysql
43 | links:
44 | - {alias}-mysql
45 | environment:
46 | - VIRTUAL_HOST={project}
47 | - VIRTUAL_PORT=80
48 | - WEB_DOCUMENT_ROOT=/var/www/app/public
49 | # - LETSENCRYPT_EMAIL=it@{project}
50 | # - LETSENCRYPT_HOST={project}
51 |
--------------------------------------------------------------------------------
/samples/laravel/configure.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CONFIGURE_DIR=${1}
4 |
5 | cd "${CONFIGURE_DIR}" || exit
6 |
7 | CONFIGURE_DIR=${1}
8 | CONFIGURE_PROJECT=${2}
9 |
10 | alias=$(echo "${CONFIGURE_PROJECT}" | cut -d. -f1)
11 | echo -n "Type an alias to project [${alias}]: "
12 | read -r CONFIGURE_ALIAS
13 | if [[ -z "${CONFIGURE_ALIAS}" ]]; then
14 | CONFIGURE_ALIAS="${alias}"
15 | fi
16 |
17 | CONFIGURE_ROOT="$(date +%s | sha256sum | base64 | head -c 16 ; echo)"
18 | CONFIGURE_PORT="3306"
19 | CONFIGURE_USER="$(date +%s | sha1sum | base64 | head -c 8 ; echo)"
20 | CONFIGURE_PASSWORD="$(date +%s | md5sum | base64 | head -c 16 ; echo)"
21 |
22 | # find ${APP} -type f -exec sed -i "s/{project}/${CONFIGURE_PROJECT}/g" {} \; > /dev/null
23 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{alias}/${CONFIGURE_ALIAS}/g" {} \; > /dev/null
24 |
25 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{root}/${CONFIGURE_ROOT}/g" {} \; > /dev/null
26 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{port}/${CONFIGURE_PORT}/g" {} \; > /dev/null
27 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{database}/${CONFIGURE_ALIAS}/g" {} \; > /dev/null
28 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{user}/${CONFIGURE_USER}/g" {} \; > /dev/null
29 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{password}/${CONFIGURE_PASSWORD}/g" {} \; > /dev/null
30 |
31 | wget -O latest.tar.gz https://codeload.github.com/laravel/laravel/tar.gz/8.x
32 |
33 | /bin/tar -xzf latest.tar.gz --strip-components 1 -C .
34 |
35 | cp .env.stage .env
36 | cp docker-compose.yml.stage docker-compose.yml
37 |
--------------------------------------------------------------------------------
/samples/laravel/repo/hooks/post-receive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR_NAME=$(dirname "$(readlink -f "${0}")")
4 | BASE=$(dirname "$(readlink -f "${DIR_NAME}/../..")")
5 | PROJECT="{project}"
6 | APP="${BASE}/${PROJECT}/app"
7 | BRANCH="master"
8 |
9 | function __plot
10 | {
11 | printf "\033[0;32m%s\033[0m \n" "${1}"
12 | }
13 |
14 | cd "${APP}" || exit
15 |
16 | # hook pre-checkout
17 | __plot "[1/5] Hook 'pre-checkout'"
18 | if [[ -f ".tevun/hooks/pre-checkout.sh" ]]; then
19 | bash .tevun/hooks/pre-checkout.sh "${APP}" "${PROJECT}"
20 | fi
21 |
22 | cd "$(dirname "${DIR_NAME}")" || exit
23 |
24 | __plot "[2/5] Checkout"
25 | GIT_WORK_TREE="${APP}" git checkout -f ${BRANCH}
26 |
27 | cd "${APP}" || exit
28 |
29 | # hook post-checkout
30 | __plot "[3/5] Hook post-checkout"
31 | if [[ -f ".tevun/hooks/post-checkout.sh" ]]; then
32 | bash .tevun/hooks/post-checkout.sh "${APP}" "${PROJECT}"
33 | fi
34 |
35 | # hook install
36 | __plot "[4/5] Hook 'install'"
37 | if [[ -f ".tevun/hooks/install.sh" ]]; then
38 | bash .tevun/hooks/install.sh "${APP}" "${PROJECT}"
39 | fi
40 |
41 | TEVUN_IS_READY="yes"
42 | READY=".tevun-ready"
43 | if [[ ! -f ${READY} ]]; then
44 | TEVUN_IS_READY="no"
45 | fi
46 |
47 | # hook setup
48 | __plot "[5/5] Hook 'setup' (is ready: ${TEVUN_IS_READY})"
49 | if [[ -f ".tevun/hooks/setup.sh" ]]; then
50 | if [[ ${TEVUN_IS_READY} = "no" ]]; then
51 | bash .tevun/hooks/setup.sh "${APP}" "${PROJECT}"
52 | touch ${READY}
53 | fi
54 | fi
55 |
--------------------------------------------------------------------------------
/samples/laravel/repo/hooks/pre-receive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #read old new ref
4 | #author=$(git log -1 $ref --pretty=%an)
5 | #committer=$(git log -1 $ref --pretty=%cn)
6 | #echo author:$author
7 | #echo committer:$committer
--------------------------------------------------------------------------------
/samples/php/app/.env.stage:
--------------------------------------------------------------------------------
1 | COMPOSE_PROJECT_NAME={project}
2 |
3 | MYSQL_ROOT_PASSWORD={root}
4 |
5 | MYSQL_HOST={alias}-mysql
6 | MYSQL_PORT={port}
7 | MYSQL_DATABASE={database}
8 | MYSQL_USER={user}
9 | MYSQL_PASSWORD={password}
10 |
--------------------------------------------------------------------------------
/samples/php/app/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | image: docker:git
2 |
3 | before_script:
4 | - mkdir -p ~/.ssh
5 | - echo "${DEPLOY_SERVER_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
6 | - chmod 600 ~/.ssh/id_rsa
7 | - eval "$(ssh-agent -s)"
8 | - ssh-add ~/.ssh/id_rsa
9 | - echo ${DEPLOY_HOST}
10 | - ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
11 |
12 | deploy:
13 | only:
14 | - master
15 | script:
16 | - echo "Deploy to ${DEPLOY_REMOTE}"
17 | - git remote add deploy ${DEPLOY_REMOTE}
18 | - git push deploy master --force
19 |
--------------------------------------------------------------------------------
/samples/php/app/.tevun/hooks/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #cd ${1}
4 |
5 | echo " ~> [hooks\install.sh] on [${1}, ${2}]"
6 |
7 | #docker exec ${container} composer.phar install \
8 | # --no-ansi --no-dev --no-interaction \
9 | # --no-progress --no-scripts --optimize-autoloader
10 |
--------------------------------------------------------------------------------
/samples/php/app/.tevun/hooks/post-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\post-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ -f "docker-compose.yml" ]]; then
8 | docker-compose rm
9 | docker-compose up -d
10 | fi
11 |
--------------------------------------------------------------------------------
/samples/php/app/.tevun/hooks/pre-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\pre-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ "$(docker ps -q -f name=${2}-app)" ]]; then
8 | docker-compose down
9 | fi
10 |
11 | # rm -rf ./*
12 |
--------------------------------------------------------------------------------
/samples/php/app/.tevun/hooks/setup.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\setup.sh] on [${1}, ${2}]"
6 |
7 | cp .env.stage .env
8 | cp docker-compose.yml.stage docker-compose.yml
9 |
10 | #docker exec {container} php artisan key:generate
11 |
--------------------------------------------------------------------------------
/samples/php/app/docker-compose.yml.stage:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | networks:
4 | reverse-proxy:
5 | external:
6 | name: reverse-proxy
7 | internal:
8 | driver: bridge
9 |
10 | volumes:
11 | {alias}-mysql_data:
12 | driver: local
13 |
14 | services:
15 | {alias}-mysql:
16 | image: mysql:5.7
17 | container_name: ${MYSQL_HOST}
18 | restart: always
19 | networks:
20 | - internal
21 | volumes:
22 | - {alias}-mysql_data:/var/lib/mysql
23 | - .:/var/www/app
24 | working_dir: /var/www/app
25 | environment:
26 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
27 | - MYSQL_DATABASE=${MYSQL_DATABASE}
28 | - MYSQL_USER=${MYSQL_USER}
29 | - MYSQL_PASSWORD=${MYSQL_PASSWORD}
30 |
31 | {alias}-nginx:
32 | image: webdevops/php-nginx:8.0
33 | container_name: {alias}-nginx
34 | restart: always
35 | networks:
36 | - reverse-proxy
37 | - internal
38 | volumes:
39 | - .:/var/www/app
40 | working_dir: /var/www/app
41 | depends_on:
42 | - {alias}-mysql
43 | links:
44 | - {alias}-mysql
45 | environment:
46 | - VIRTUAL_HOST={project}
47 | - VIRTUAL_PORT=80
48 | - WEB_DOCUMENT_ROOT=/var/www/app/public
49 | # - LETSENCRYPT_EMAIL=it@{project}
50 | # - LETSENCRYPT_HOST={project}
51 |
--------------------------------------------------------------------------------
/samples/php/app/public/index.php:
--------------------------------------------------------------------------------
1 | Your domain {project} is working!
2 |
--------------------------------------------------------------------------------
/samples/php/configure.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CONFIGURE_DIR=${1}
4 | CONFIGURE_PROJECT=${2}
5 |
6 | #cp ${APP_DIR}/.env.stage ${APP_DIR}/.env
7 | #cp ${APP_DIR}/docker-compose.yml.stage ${APP_DIR}/docker-compose.yml
8 |
9 | alias=$(echo "${CONFIGURE_PROJECT}" | cut -d. -f1)
10 | echo -n "Type an alias to project [${alias}]: "
11 | read -r CONFIGURE_ALIAS
12 | if [[ -z "${CONFIGURE_ALIAS}" ]]; then
13 | CONFIGURE_ALIAS="${alias}"
14 | fi
15 |
16 | CONFIGURE_ROOT="$(date +%s | sha256sum | base64 | head -c 16 ; echo)"
17 | CONFIGURE_PORT="3306"
18 | CONFIGURE_USER="$(date +%s | sha1sum | base64 | head -c 8 ; echo)"
19 | CONFIGURE_PASSWORD="$(date +%s | md5sum | base64 | head -c 16 ; echo)"
20 |
21 | # find ${APP} -type f -exec sed -i "s/{project}/${CONFIGURE_PROJECT}/g" {} \; > /dev/null
22 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{alias}/${CONFIGURE_ALIAS}/g" {} \; > /dev/null
23 |
24 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{root}/${CONFIGURE_ROOT}/g" {} \; > /dev/null
25 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{port}/${CONFIGURE_PORT}/g" {} \; > /dev/null
26 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{database}/${CONFIGURE_ALIAS}/g" {} \; > /dev/null
27 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{user}/${CONFIGURE_USER}/g" {} \; > /dev/null
28 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{password}/${CONFIGURE_PASSWORD}/g" {} \; > /dev/null
29 |
30 | cp .env.stage .env
31 | cp docker-compose.yml.stage docker-compose.yml
32 |
--------------------------------------------------------------------------------
/samples/php/repo/hooks/post-receive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR_NAME=$(dirname $(readlink -f ${0}))
4 | BASE=$(dirname $(readlink -f "${DIR_NAME}/../.."))
5 | PROJECT="{project}"
6 | APP="${BASE}/${PROJECT}/app"
7 | BRANCH="master"
8 |
9 | function __plot
10 | {
11 | printf "\033[0;32m${1}\033[0m \n"
12 | }
13 |
14 | cd ${APP}
15 |
16 | # hook pre-checkout
17 | __plot "[1/5] Hook 'pre-checkout'"
18 | if [[ -f ".tevun/hooks/pre-checkout.sh" ]]; then
19 | bash .tevun/hooks/pre-checkout.sh ${APP} ${PROJECT}
20 | fi
21 |
22 | TEVUN_IS_READY="yes"
23 | READY=".tevun-ready"
24 | if [[ ! -f ${READY} ]]; then
25 | TEVUN_IS_READY="no"
26 | fi
27 |
28 | # hook setup
29 | __plot "[2/5] Hook 'setup' (is ready: ${TEVUN_IS_READY})"
30 | if [[ -f ".tevun/hooks/setup.sh" ]]; then
31 | if [[ ${TEVUN_IS_READY} = "no" ]]; then
32 | bash .tevun/hooks/setup.sh ${APP} ${PROJECT}
33 | touch ${READY}
34 | fi
35 | fi
36 |
37 | cd $(dirname ${DIR_NAME})
38 |
39 | __plot "[3/5] Checkout"
40 | GIT_WORK_TREE="${APP}" git checkout -f ${BRANCH}
41 |
42 | cd ${APP}
43 |
44 | # hook post-checkout
45 | __plot "[4/5] Hook post-checkout"
46 | if [[ -f ".tevun/hooks/post-checkout.sh" ]]; then
47 | bash .tevun/hooks/post-checkout.sh ${APP} ${PROJECT}
48 | fi
49 |
50 | # hook install
51 | __plot "[5/5] Hook 'install'"
52 | if [[ -f ".tevun/hooks/install.sh" ]]; then
53 | bash .tevun/hooks/install.sh ${APP} ${PROJECT}
54 | fi
55 |
--------------------------------------------------------------------------------
/samples/php/repo/hooks/pre-receive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #read old new ref
4 | #author=$(git log -1 $ref --pretty=%an)
5 | #committer=$(git log -1 $ref --pretty=%cn)
6 | #echo author:$author
7 | #echo committer:$committer
--------------------------------------------------------------------------------
/samples/wordpress/app/.env.stage:
--------------------------------------------------------------------------------
1 | COMPOSE_PROJECT_NAME={project}
2 |
3 | MYSQL_ROOT_PASSWORD={root}
4 |
5 | MYSQL_HOST={alias}-mysql
6 | MYSQL_PORT={port}
7 | MYSQL_DATABASE={database}
8 | MYSQL_USER={user}
9 | MYSQL_PASSWORD={password}
10 |
--------------------------------------------------------------------------------
/samples/wordpress/app/.gitlab-ci.yml:
--------------------------------------------------------------------------------
1 | image: docker:git
2 |
3 | before_script:
4 | - mkdir -p ~/.ssh
5 | - echo "${DEPLOY_SERVER_PRIVATE_KEY}" | tr -d '\r' > ~/.ssh/id_rsa
6 | - chmod 600 ~/.ssh/id_rsa
7 | - eval "$(ssh-agent -s)"
8 | - ssh-add ~/.ssh/id_rsa
9 | - echo ${DEPLOY_HOST}
10 | - ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
11 |
12 | deploy:
13 | only:
14 | - master
15 | script:
16 | - echo "Deploy to ${DEPLOY_REMOTE}"
17 | - git remote add deploy ${DEPLOY_REMOTE}
18 | - git push deploy master --force
19 |
--------------------------------------------------------------------------------
/samples/wordpress/app/.tevun/hooks/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #cd ${1}
4 |
5 | echo " ~> [hooks\install.sh] on [${1}, ${2}]"
6 |
7 | #docker exec ${container} composer.phar install \
8 | # --no-ansi --no-dev --no-interaction \
9 | # --no-progress --no-scripts --optimize-autoloader
10 |
--------------------------------------------------------------------------------
/samples/wordpress/app/.tevun/hooks/post-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\post-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ -f "docker-compose.yml" ]]; then
8 | docker-compose rm
9 | docker-compose up -d
10 | fi
11 |
--------------------------------------------------------------------------------
/samples/wordpress/app/.tevun/hooks/pre-checkout.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\pre-checkout.sh] on [${1}, ${2}]"
6 |
7 | if [[ "$(docker ps -q -f name=${2}-app)" ]]; then
8 | docker-compose down
9 | fi
10 |
11 | # rm -rf ./*
12 |
--------------------------------------------------------------------------------
/samples/wordpress/app/.tevun/hooks/setup.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd ${1}
4 |
5 | echo " ~> [hooks\setup.sh] on [${1}, ${2}]"
6 |
7 | #docker exec {container} php artisan key:generate
8 |
--------------------------------------------------------------------------------
/samples/wordpress/app/docker-compose.yml.stage:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | networks:
4 | reverse-proxy:
5 | external:
6 | name: reverse-proxy
7 | internal:
8 | driver: bridge
9 |
10 | volumes:
11 | {alias}-mysql_data:
12 | driver: local
13 |
14 | services:
15 | {alias}-mysql:
16 | image: mysql:5.7
17 | container_name: ${MYSQL_HOST}
18 | restart: always
19 | networks:
20 | - internal
21 | volumes:
22 | - {alias}-mysql_data:/var/lib/mysql
23 | - .:/var/www/app
24 | working_dir: /var/www/app
25 | environment:
26 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
27 | - MYSQL_DATABASE=${MYSQL_DATABASE}
28 | - MYSQL_USER=${MYSQL_USER}
29 | - MYSQL_PASSWORD=${MYSQL_PASSWORD}
30 |
31 | {alias}-nginx:
32 | image: webdevops/php-nginx:8.0
33 | container_name: {alias}-nginx
34 | restart: always
35 | networks:
36 | - reverse-proxy
37 | - internal
38 | volumes:
39 | - .:/var/www/app
40 | working_dir: /var/www/app
41 | depends_on:
42 | - {alias}-mysql
43 | links:
44 | - {alias}-mysql
45 | environment:
46 | - VIRTUAL_HOST={project}
47 | - VIRTUAL_PORT=80
48 | - WEB_DOCUMENT_ROOT=/var/www/app/public
49 | # - LETSENCRYPT_EMAIL=it@{project}
50 | # - LETSENCRYPT_HOST={project}
51 |
--------------------------------------------------------------------------------
/samples/wordpress/app/public/index.php:
--------------------------------------------------------------------------------
1 | Your domain {project} is working!
2 |
--------------------------------------------------------------------------------
/samples/wordpress/configure.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CONFIGURE_DIR=${1}
4 |
5 | cd "${CONFIGURE_DIR}" || exit
6 |
7 | CONFIGURE_DIR=${1}
8 | CONFIGURE_PROJECT=${2}
9 |
10 | alias=$(echo "${CONFIGURE_PROJECT}" | cut -d. -f1)
11 | echo -n "Type an alias to project [${alias}]: "
12 | read -r CONFIGURE_ALIAS
13 | if [[ -z "${CONFIGURE_ALIAS}" ]]; then
14 | CONFIGURE_ALIAS="${alias}"
15 | fi
16 |
17 | CONFIGURE_ROOT="$(date +%s | sha256sum | base64 | head -c 16 ; echo)"
18 | CONFIGURE_PORT="3306"
19 | CONFIGURE_USER="$(date +%s | sha1sum | base64 | head -c 8 ; echo)"
20 | CONFIGURE_PASSWORD="$(date +%s | md5sum | base64 | head -c 16 ; echo)"
21 |
22 | # find ${APP} -type f -exec sed -i "s/{project}/${CONFIGURE_PROJECT}/g" {} \; > /dev/null
23 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{alias}/${CONFIGURE_ALIAS}/g" {} \; > /dev/null
24 |
25 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{root}/${CONFIGURE_ROOT}/g" {} \; > /dev/null
26 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{port}/${CONFIGURE_PORT}/g" {} \; > /dev/null
27 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{database}/${CONFIGURE_ALIAS}/g" {} \; > /dev/null
28 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{user}/${CONFIGURE_USER}/g" {} \; > /dev/null
29 | find "${CONFIGURE_DIR}" -type f -exec sed -i "s/{password}/${CONFIGURE_PASSWORD}/g" {} \; > /dev/null
30 |
31 | wget https://wordpress.org/latest.tar.gz
32 |
33 | /bin/tar -xzf latest.tar.gz
34 | /bin/rm -rf public
35 | /bin/mv wordpress/ public/
36 |
37 | cp .env.stage .env
38 | cp docker-compose.yml.stage docker-compose.yml
39 |
--------------------------------------------------------------------------------
/samples/wordpress/repo/hooks/post-receive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | DIR_NAME=$(dirname $(readlink -f ${0}))
4 | BASE=$(dirname $(readlink -f "${DIR_NAME}/../.."))
5 | PROJECT="{project}"
6 | APP="${BASE}/${PROJECT}/app"
7 | BRANCH="master"
8 |
9 | function __plot
10 | {
11 | printf "\033[0;32m${1}\033[0m \n"
12 | }
13 |
14 | cd ${APP}
15 |
16 | # hook pre-checkout
17 | __plot "[1/5] Hook 'pre-checkout'"
18 | if [[ -f ".tevun/hooks/pre-checkout.sh" ]]; then
19 | bash .tevun/hooks/pre-checkout.sh ${APP} ${PROJECT}
20 | fi
21 |
22 | TEVUN_IS_READY="yes"
23 | READY=".tevun-ready"
24 | if [[ ! -f ${READY} ]]; then
25 | TEVUN_IS_READY="no"
26 | fi
27 |
28 | # hook setup
29 | __plot "[2/5] Hook 'setup' (is ready: ${TEVUN_IS_READY})"
30 | if [[ -f ".tevun/hooks/setup.sh" ]]; then
31 | if [[ ${TEVUN_IS_READY} = "no" ]]; then
32 | bash .tevun/hooks/setup.sh ${APP} ${PROJECT}
33 | touch ${READY}
34 | fi
35 | fi
36 |
37 | cd $(dirname ${DIR_NAME})
38 |
39 | __plot "[3/5] Checkout"
40 | GIT_WORK_TREE="${APP}" git checkout -f ${BRANCH}
41 |
42 | cd ${APP}
43 |
44 | # hook post-checkout
45 | __plot "[4/5] Hook post-checkout"
46 | if [[ -f ".tevun/hooks/post-checkout.sh" ]]; then
47 | bash .tevun/hooks/post-checkout.sh ${APP} ${PROJECT}
48 | fi
49 |
50 | # hook install
51 | __plot "[5/5] Hook 'install'"
52 | if [[ -f ".tevun/hooks/install.sh" ]]; then
53 | bash .tevun/hooks/install.sh ${APP} ${PROJECT}
54 | fi
55 |
--------------------------------------------------------------------------------
/samples/wordpress/repo/hooks/pre-receive:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #read old new ref
4 | #author=$(git log -1 $ref --pretty=%an)
5 | #committer=$(git log -1 $ref --pretty=%cn)
6 | #echo author:$author
7 | #echo committer:$committer
--------------------------------------------------------------------------------
/tevun-functions.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | function __plot
4 | {
5 | printf "\033[0;32m${1}\033[0m \n"
6 | }
--------------------------------------------------------------------------------
/tevun.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ACTION=${1}
4 | TEVUN_DIR=$(dirname $(readlink -f ${0}))
5 |
6 | cd ${TEVUN_DIR}
7 | source ./tevun-functions.sh
8 |
9 | if [[ ! -f .env ]]; then
10 | cp .env.sample .env
11 | fi
12 | source .env
13 |
14 | if [[ ! -f .key ]]; then
15 | TEVUN_UUID=$(cat /proc/sys/kernel/random/uuid)
16 | echo ${TEVUN_UUID} > .key
17 | fi
18 | TEVUN_UUID=$(cat .key)
19 |
20 | case ${ACTION} in
21 | "setup")
22 | source ./commands/setup.sh
23 | ;;
24 | "ps")
25 | source ./commands/utils/ps.sh
26 | ;;
27 |
28 | "create")
29 | source ./commands/project/create.sh
30 | ;;
31 | "destroy")
32 | source ./commands/project/destroy.sh
33 | ;;
34 |
35 | "user")
36 | source ./commands/credential/user.sh
37 | ;;
38 | "ssh")
39 | source ./commands/credential/ssh.sh
40 | ;;
41 | "register")
42 | source ./commands/credential/register.sh
43 | ;;
44 |
45 | "lets-encrypt/renew")
46 | source ./commands/utils/lets-encrypt/renew.sh
47 | ;;
48 | "lets-encrypt/status")
49 | source ./commands/utils/lets-encrypt/status.sh
50 | ;;
51 |
52 | "ubuntu/locale")
53 | source ./commands/utils/ubuntu/locale.sh
54 | ;;
55 | "requirement")
56 | INSTALLER="${TEVUN_DIR}/installers/${2}.sh"
57 | if [[ -f ${INSTALLER} ]];then
58 | source ${INSTALLER}
59 | fi
60 | ;;
61 |
62 | # "start")
63 | # source ./commands/start.sh ${TEVUN_DIR} ${2}
64 | # ;;
65 | # "stop")
66 | # source ./commands/stop.sh ${TEVUN_DIR} ${2}
67 | # ;;
68 | # "up")
69 | # source ./commands/up.sh ${TEVUN_DIR} ${2}
70 | # ;;
71 | # "down")
72 | # source ./commands/down.sh ${TEVUN_DIR} ${2}
73 | # ;;
74 | "ll")
75 | source ./commands/project/projects.sh ${TEVUN_DIR}
76 | ;;
77 | "pull")
78 | source ./commands/project/pull.sh ${TEVUN_DIR}
79 | ;;
80 | # "password")
81 | # source ./commands/utils/password.sh ${TEVUN_DIR}
82 | # ;;
83 |
84 | # "compose")
85 | # source ./commands/utils/compose.sh ${TEVUN_DIR} ${2}
86 | # ;;
87 |
88 | *)
89 | echo " ____ ____"
90 | echo ".___________. ._______.\ \ / /.__ __. .__ __."
91 | echo "| | | ____| \ \ / / | | | | | \ | |"
92 | echo "\`---| |----\` | |__ \ \ / / | | | | | \| |"
93 | echo " | | | __| \ \/ / | | | | | . \` |"
94 | echo " | | | |____ \ / | \`--' | | |\ |"
95 | echo " |__| |_______| \ / \______/ |__| \__|"
96 | echo " \__/"
97 | echo "Usage: tevun COMMAND"
98 | echo ""
99 | echo "A project container agile"
100 | echo ""
101 | echo "Administrative Commands:"
102 | echo "setup Start usage server"
103 | echo "ps Show running containers"
104 | echo "user Create an user and configure system to use it"
105 | echo "ssh Configure ssh with user that will be used to execute the commands"
106 | # echo "password Generate a random password"
107 | echo "ll List the projects folder"
108 | echo "pull Pull new images of each projects and restart docker-compose"
109 |
110 | echo ""
111 | echo "Project Management Commands:"
112 | echo "create Create project"
113 | echo "destroy Destroy project"
114 | # echo "start Apply start on project"
115 | # echo "stop Apply stop on project"
116 | # echo "up Apply up on project"
117 | # echo "down Apply up on project"
118 |
119 | echo ""
120 | echo "Util Commands:"
121 | echo "ubuntu/locale Fix locale on Ubuntu Server"
122 | echo "lets-encrypt/renew Force renew certificates"
123 | echo "lets-encrypt/status Show certificate status"
124 | echo "requirement {distro} Install requirements to your distro [ubuntu, debian, etc]"
125 | echo ""
126 | ;;
127 | esac
128 |
129 | function __tevun
130 | {
131 | local cur prev opts
132 | COMPREPLY=()
133 | cur="${COMP_WORDS[COMP_CWORD]}"
134 | prev="${COMP_WORDS[COMP_CWORD-1]}"
135 | opts="setup password user ps projects \
136 | create destroy start stop up down \
137 | ubuntu/locale lets-encrypt/renew lets-encrypt/status requirement \
138 | help"
139 | if [[ ${cur} == * ]] ; then
140 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
141 | return 0
142 | fi
143 | }
144 |
145 | complete __tevun tevun
146 |
--------------------------------------------------------------------------------