This pipeline project template is created to support containerization faster.
loadbalancer (80,443)
|
--------------------------------------------------
| |
development_network production_network
| |
| ---------------------------
| | |
myapp (80) myfront (80) myback (80)
(dev.myapp.com) (myfront.com) (myback.com)
- Server, PC or laptop
- Internet access
- git installed
- little bit of ✨Magic ✨
- Docker
- Docker Compose
- Nginx
- Git
- loadbalancer with nginx alpine
- docker-compose network managed
- services/
- development/ <-- project / app folder
- .env <-- env file for docker-compose
- docker-compose.yaml <-- docker-compose config
- production/
- .env
- docker-compose.yaml
- loadbalancer/
- docker-compose.yaml
- certs/
- nginx.tmpl
- start.sh <-- ✨Magic ✨
you need to add to your /etc/hosts
to run sample.local
domain
127.0.0.1 dev.myapp.com myfront.com myback.com
git clone https://github.com/eatrisno/compose-framework.git
cd compose-framework
./start.sh
-
cd compose-framework mkdir staging cd staging
-
Create
docker-compose.yaml
filenano docker-compose.yaml
docker-compose.yaml
:version: '3.7' services: backend-api: #<-- app name, for e.g: backend-api restart: always #<-- keep start docker when down / error image: "${BACKEND_API_REGISTERY}" #<-- image registery variable loaded from .env file networks: # - staging #<-- network alias ---------------------------------| environment: # | - VIRTUAL_HOST="api.mycompany.com" #<-- app domain alias (http://api.mycompany.com) | - VIRTUAL_PORT=80 expose: - 80 networks: # | staging: #<-- network alias for attach to service -----------| name: "staging_network" #<-- your network name
-
Create
.env
filenano .env
.env
:BACKEND_API_REGISTERY=nginx:alpine
-
Start service with this command:
docker-compose up -d backend-api
output:
Creating network "develop_network" with the default driver Creating develop_backend-api_1 ... done
-
add network to loadbalancer
docker-compose.yaml
:version: '3.7' services: nginx-proxy: restart: always image: nginxproxy/nginx-proxy:alpine volumes: - "./certs:/etc/nginx/certs" ports: - 80:80 - 443:443 volumes: - /var/run/docker.sock:/tmp/docker.sock:ro networks: - development - production - staging #<---- add this alias network networks: production: name: "production_network" development: #<---- alias network name: "development_network" #<---- network name staging: name: "staging_network"
add your certificate to
certs
folder with domain format, for example your domain is :mywebsite.com
, your cert file name ismywebsite.com.cert
your key file name ismywebsite.com.key
loadbalancer/ certs/ - mywebsite.com.cert - mywebsite.com.key
-
restart your nginx loadbalancer
docker-compose up -d
(
optional
) add to your local/etc/hosts
:sudo nano /etc/hosts echo "127.0.0.1 api.mycompany.com"
MIT
Free Software, Hell Yeah!