Skip to content

Instantly share code, notes, and snippets.

@jonasgeiler
Last active May 10, 2021 15:46
Show Gist options
  • Save jonasgeiler/daa3fc4c407142ee0656c1971199fd0f to your computer and use it in GitHub Desktop.
Save jonasgeiler/daa3fc4c407142ee0656c1971199fd0f to your computer and use it in GitHub Desktop.
Running local JS Bin using Docker + docker-compose
{
"timezone": "UTC",
"url": {
"host": "example.com",
"prefix": "/",
"ssl": true
},
"max-request-size": "1MB",
"max-age": 86400,
"store": {
"adapter": "mysql",
"mysql": {
"host": "db",
"user": "jsbin",
"password": "jsbin-secret",
"database": "jsbin"
}
},
"mail": {
"adapter": "sendmail",
"sendmail": {},
"smtp": {
"service": "Gmail",
"auth": {
"user": "",
"pass": ""
}
}
},
"server": {
"logger": "none"
},
"security": {
"allowAnonymousPreview": false
},
"session": {
"secret": "insertrandomkeyhere"
},
"github": {
"id": "",
"secret": ""
},
"api": {
"allowAnonymousReadWrite": false,
"allowAnonymousRead": true,
"requireSSL": true
}
}
version: "3"
services:
db:
image: mariadb:10.5
container_name: jsbin_db
restart: always
environment:
- MYSQL_DATABASE=jsbin
- MYSQL_USER=jsbin
- MYSQL_PASSWORD=jsbin-secret
- MYSQL_RANDOM_ROOT_PASSWORD=1
volumes:
- db_data:/var/lib/mysql
jsbin:
build: .
container_name: jsbin
ports:
- "3001:8000"
volumes:
- "./config.json:/config.json"
environment:
- JSBIN_CONFIG=/config.json
depends_on:
- db
volumes:
db_data:
FROM node:12-alpine
RUN apk --no-cache add git
RUN git clone https://github.com/jsbin/jsbin.git /jsbin
WORKDIR /jsbin
RUN npm install -g grunt-cli
RUN npm install
RUN grunt build
ENV NODE_ENV=production
ENV PORT=8000
EXPOSE 8000
CMD node .
@jonasgeiler
Copy link
Author

jonasgeiler commented Dec 4, 2020

This is intended to be used behind a reverse proxy (like nginx or caddy)

Usage

  • Put all the files into one empty directory
  • Edit config.json
    • Replace example.com with your domain name
    • Set your timezone (f.e. UTC+1)
    • Set a random session secret
    • Set your GitHub OAuth ID and secret (Instructions)
  • Run docker-compose up -d

Reverse Proxy using Caddy

Example Caddyfile entry:

bin.example.com {
  reverse_proxy localhost:3001
  file_server
  encode gzip zstd
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment