Skip to content

Instantly share code, notes, and snippets.

@torchhound
torchhound / docker-compose.test.yml
Last active November 3, 2018 06:25
mongo-crud docker/docker-compose.test.yml
version: '3'
services:
backend-test:
build:
context: ../
dockerfile: docker/Dockerfile.test
args:
port: ${PORT}
env_file:
- ../.env
@torchhound
torchhound / Dockerfile.test
Last active November 4, 2018 02:25
mongo-crud docker/Dockerfile.test
FROM docker_backend
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait
ENV NODE_ENV dev
RUN npm install && npm install -g mocha
ARG port=80
CMD /wait && mocha test/unitTests.js --exit
@torchhound
torchhound / Dockerfile.production
Last active November 4, 2018 02:25
mongo-crud docker/Dockerfile.production
FROM node:10.12.0-alpine
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait
WORKDIR /home/nodejs/app
ENV NODE_ENV prod
COPY package*.json ./
RUN npm install --only=production
ARG port=80
EXPOSE $port
COPY . ./
@torchhound
torchhound / scripts.json
Last active November 3, 2018 04:28
mongo-crud pack.json scripts
"scripts": {
"test": "docker-compose -f docker/docker-compose.test.yml up --build --abort-on-container-exit",
"production": "docker-compose -f docker/docker-compose.yml up -d",
"build": "docker-compose -f docker/docker-compose.yml build"
}
@torchhound
torchhound / docker-compose.yml
Last active November 3, 2018 06:25
mongo-crud docker/docker-compose.yml
version: '3'
services:
backend:
build:
context: ../
dockerfile: docker/Dockerfile.production
args:
port: ${PORT}
env_file:
- ../.env
@torchhound
torchhound / unitTests.js
Last active November 3, 2018 02:53
mongo-crud test/unitTests.js
const test = require('tape')
const request = require('supertest')
const express = require('express')
const Document = require('../models/Document')
const app = require('../index')
let documentId
before(done => {
app.on( 'APP_STARTED', () => {
@torchhound
torchhound / .travis.yml
Last active November 3, 2018 04:29
mongo-crud .travis.yml
services: docker
before_install:
- docker -v
- cp example.env .env
- sudo /etc/init.d/postgresql stop
- sudo service mysql stop
install:
- npm run build
@torchhound
torchhound / example.env
Created November 1, 2018 19:03
mongo-crud example.env
MONGO_INITDB_ROOT_USERNAME=example
MONGO_INITDB_ROOT_PASSWORD=example
MONGO_INITDB_DATABASE=api
MONGO_DATA_DIR=/data/db
MONGO_TEST_DATA_DIR=/data/test_db
MONGO_LOG_FILE=/var/log/mongodb/mongodb.log
PORT=80
@torchhound
torchhound / .gitignore
Created November 1, 2018 19:02
mongo-crud .gitignore
.env
node_modules/
data/
docker/data/
@torchhound
torchhound / .dockerignore
Created November 1, 2018 19:01
mongo-crud .dockerignore
.env
node_modules/
data/
LICENSE
README.md
.gitignore
.git/
example.env
.travis.yml
docker/