Skip to content

Instantly share code, notes, and snippets.

@fabianmu
Last active June 19, 2017 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabianmu/0091db3c83322f6f33c07e524dc7bd28 to your computer and use it in GitHub Desktop.
Save fabianmu/0091db3c83322f6f33c07e524dc7bd28 to your computer and use it in GitHub Desktop.
host an adonis js app on a laravel forge server via docker compose
cd /home/forge/%whateversitedir%
git pull origin master
chmod a+w storage
chmod a+w storage/user-uploads
docker-compose stop
docker-compose build
docker-compose up -d
docker exec -t app ./ace migration:run --force
version: '2'
services:
app:
build:
context: .
dockerfile: Dockerfile
command: npm run serve
container_name: app
environment:
- NODE_ENV=production
volumes:
- .:/home/app
- /home/app/node_modules
ports:
- "3333:3333"
mysql:
image: mysql:5.7
container_name: mysql
ports:
- "3307:3306" #this exposes the mysql-containter to 3307@host buy it'll remain exposed at 3306 to the app
environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
FROM node:7
RUN useradd --user-group --create-home --shell /bin/false app
ENV HOME=/home/app
COPY package.json $HOME/
RUN chown -R app:app $HOME/*
USER root
WORKDIR $HOME
RUN npm i -g adonis-cli gulp
USER app
RUN npm install
# this assumes that you're using SSL via let's encrypt. basically just remove all the PHP shizzle and replace it with the `location` chunk to proxy the domain to the node process
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/%whateversitedir%/before/*;
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name %domain%;
root /home/forge/%whateversitedir%/public;
# FORGE SSL (DO NOT REMOVE!)
# Basically just keep the SSL stuff from forge as it is
ssl_certificate /etc/nginx/ssl/%whateversitedir%/server.crt;
ssl_certificate_key /etc/nginx/ssl/%whateversitedir%/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers '%whatevercipher%, just keep this form the original file%';
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
charset utf-8;
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/%whateversitedir%/server/*;
location / {
proxy_pass http://localhost:3333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location ~ /\.ht {
deny all;
}
}
# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/%whateversitedir%/after/*;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment