This commit is contained in:
Henry Oswald 2018-01-16 12:27:36 +00:00
parent a70a216c52
commit c23b700927
6 changed files with 1503 additions and 319 deletions

View file

@ -0,0 +1,27 @@
FROM node:8.9.1
WORKDIR /app
COPY package.json /app/
RUN npm install --quiet
COPY config /app/config
COPY test /app/test
COPY app /app/app
COPY app.coffee /app
RUN npm run compile:all
FROM node:8.9.1
COPY --from=0 /app /app
# All app and node_modules will be owned by root.
# The app will run as the 'app' user, and so not have write permissions
# on any files it doesn't need.
RUN useradd --user-group --create-home --home-dir /app --shell /bin/false app
USER app
WORKDIR /app
EXPOSE 3009
CMD ["node","app.js"]

View file

@ -0,0 +1,62 @@
NPM := docker-compose -f docker-compose.yml ${DOCKER_COMPOSE_FLAGS} run --rm npm npm
BUILD_NUMBER ?= local
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
PROJECT_NAME = filestore
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
DOCKER_COMPOSE := docker-compose ${DOCKER_COMPOSE_FLAGS}
all: install test
@echo "Run:"
@echo " make install to set up the project dependencies (in docker)"
@echo " make test to run all the tests for the project (in docker)"
@echo " make run to run the app (natively)"
install:
$(NPM) install
run:
$(NPM) run start
clean:
rm -f app.js
rm -rf app/js
rm -rf test/unit/js
rm -rf test/acceptance/js
# Deletes node_modules volume
docker-compose down --volumes
test: test_unit test_acceptance
test_unit:
$(DOCKER_COMPOSE) run --rm test_unit -- ${MOCHA_ARGS}
test_acceptance: ci_clean # clear the database before each acceptance test run
$(DOCKER_COMPOSE) run --rm test_acceptance -- ${MOCHA_ARGS}
build:
docker build --pull --tag quay.io/sharelatex/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) .
publish:
docker push quay.io/sharelatex/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
ci:
# On the CI server, we want to run our tests in the image that we
# have built for deployment, which is what the docker-compose.ci.yml
# override does.
PROJECT_NAME=$(PROJECT_NAME) \
BRANCH_NAME=$(BRANCH_NAME) \
BUILD_NUMBER=$(BUILD_NUMBER) \
DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" \
$(MAKE) build test publish
ci_clean:
PROJECT_NAME=$(PROJECT_NAME) \
BRANCH_NAME=$(BRANCH_NAME) \
BUILD_NUMBER=$(BUILD_NUMBER) \
DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" \
$(DOCKER_COMPOSE) down
.PHONY:
all install compile clean test test_unit test_acceptance \
test_acceptance_start_service test_acceptance_stop_service \
test_acceptance_run build publish ci ci_clean

View file

@ -96,7 +96,7 @@ app.post "/shutdown", (req, res)->
app.get '/status', (req, res)->
if appIsOk
res.send('filestore sharelatex up')
res.send('filestore sharelatex up - v2')
else
logger.log "app is not ok - shutting down"
res.send("server is being shut down", 500)
@ -112,7 +112,7 @@ app.get '*', (req, res)->
server = require('http').createServer(app)
port = settings.internal.filestore.port or 3009
host = settings.internal.filestore.host or "localhost"
host = "0.0.0.0"
beginShutdown = () ->
if appIsOk
@ -128,7 +128,7 @@ beginShutdown = () ->
process.disconnect?()
logger.log "server will stop accepting connections"
server.listen port, host, ->
server.listen port, ->
logger.info "Filestore starting up, listening on #{host}:#{port}"
process.on 'SIGTERM', () ->

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,18 @@
"type": "git",
"url": "https://github.com/sharelatex/filestore-sharelatex.git"
},
"scripts": {
"test:acceptance:run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
"test:acceptance": "npm run compile:app && npm run compile:acceptance_tests && npm run test:acceptance:run -- $@",
"test:unit:run": "mocha --recursive --reporter spec $@ test/unit/js",
"test:unit": "npm run compile:app && npm run compile:unit_tests && npm run test:unit:run -- $@",
"compile:unit_tests": "coffee -o test/unit/js -c test/unit/coffee",
"compile:acceptance_tests": "coffee -o test/acceptance/js -c test/acceptance/coffee",
"compile:app": "coffee -o app/js -c app/coffee && coffee -c app.coffee",
"compile:all": "npm run compile:app && npm run compile:unit_tests && npm run compile:acceptance_tests",
"start": "npm run compile:app && node app.js",
"nodemon": "nodemon --config nodemon.json"
},
"dependencies": {
"async": "~0.2.10",
"aws-sdk": "^2.1.39",