Bläddra i källkod

Add docker-compose

Craig Fletcher 4 år sedan
förälder
incheckning
086655b567
5 ändrade filer med 34 tillägg och 2 borttagningar
  1. 1 0
      .env.example
  2. 1 0
      .gitignore
  3. 5 1
      README.md
  4. 25 0
      docker-compose.yml
  5. 2 1
      src/index.js

+ 1 - 0
.env.example

@@ -0,0 +1 @@
+REDIS_PASS=password123

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 node_modules
 logs
+redis
 .env

+ 5 - 1
README.md

@@ -10,7 +10,7 @@ Quick and dirty API boilerplate, using:
 There are many limitations to this configuration, it is intended as a
 debugging/prototyping tool.
 
-There are fairly few dependencies in this boilerplate, and most things are
+There are fairly few dependencies and most things are
 simply factories with instances passed in.
 
 
@@ -27,6 +27,10 @@ start(
 )
 ```
 
+The included example uses docker and docker-compose, so the db host is set to
+"redis" and the restify server listens on 0.0.0.0. You'll need to rename
+.env.example to .env and change the password.
+
 
 ## Storage
 

+ 25 - 0
docker-compose.yml

@@ -0,0 +1,25 @@
+version: '3.2'
+
+services:
+
+  redis:
+    image: "redis:alpine"
+    command: redis-server --requirepass ${REDIS_PASS}
+    expose:
+      - "6379"
+    volumes:
+      - ${PWD}/redis/data:/data
+      - ${PWD}/redis/conf:/usr/local/etc/redis/redis.conf
+  app:
+    image: "node:lts-alpine"
+    working_dir: /app
+    environment:
+      - NODE_ENV=production
+      - REDIS_PASS=${REDIS_PASS}
+    volumes:
+      - ${PWD}:/app
+    ports:
+      - "8080:8080"
+    expose:
+      - "8080"
+    command: "npm start"

+ 2 - 1
src/index.js

@@ -1,4 +1,5 @@
+import { env } from 'process';
 import start from './easy-api.js';
 import routes from './routes/index.js';
 
-start(routes, 'localhost', 8080, { password: 'password123' }, { name: 'example-easy-api' });
+start(routes, '0.0.0.0', 8080, { host: 'redis', password: env.REDIS_PASS }, { name: 'example-easy-api' });