tests pass under app user
This commit is contained in:
25
Dockerfile
25
Dockerfile
@@ -1,4 +1,4 @@
|
|||||||
FROM node:6.13.0
|
FROM node:6.13.0 as app
|
||||||
|
|
||||||
COPY ./ /app
|
COPY ./ /app
|
||||||
|
|
||||||
@@ -6,11 +6,22 @@ WORKDIR /app
|
|||||||
|
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
|
|
||||||
|
RUN npm run compile:all
|
||||||
|
|
||||||
|
FROM node:6.13.0
|
||||||
|
|
||||||
|
COPY --from=app /app /app
|
||||||
|
|
||||||
|
WORKDIR /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/bash app
|
||||||
|
|
||||||
RUN [ -e ./install_deps.sh ] && ./install_deps.sh
|
RUN [ -e ./install_deps.sh ] && ./install_deps.sh
|
||||||
|
|
||||||
RUN npm run compile
|
USER app
|
||||||
|
CMD ["node","app.js"]
|
||||||
ENV SHARELATEX_CONFIG /app/config/settings.production.coffee
|
|
||||||
ENV NODE_ENV production
|
|
||||||
|
|
||||||
CMD ["node","/app/app.js"]
|
|
||||||
|
|||||||
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
@@ -9,34 +9,9 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Install') {
|
stage('Build') {
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'node:6.13.0'
|
|
||||||
args "-v /var/lib/jenkins/.npm:/tmp/.npm -e HOME=/tmp"
|
|
||||||
reuseNode true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
steps {
|
||||||
// we need to disable logallrefupdates, else git clones
|
sh 'make build'
|
||||||
// during the npm install will require git to lookup the
|
|
||||||
// user id which does not exist in the container's
|
|
||||||
// /etc/passwd file, causing the clone to fail.
|
|
||||||
sh 'git config --global core.logallrefupdates false'
|
|
||||||
sh 'rm -rf node_modules'
|
|
||||||
sh 'npm install && npm rebuild'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Compile') {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'node:6.13.0'
|
|
||||||
reuseNode true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh 'npm run compile:all'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,12 +29,7 @@ pipeline {
|
|||||||
|
|
||||||
stage('Package and publish build') {
|
stage('Package and publish build') {
|
||||||
steps {
|
steps {
|
||||||
sh 'echo ${BUILD_NUMBER} > build_number.txt'
|
sh 'make publish'
|
||||||
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
|
|
||||||
sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
|
|
||||||
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
|
|
||||||
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
Makefile
5
Makefile
@@ -28,5 +28,10 @@ test_acceptance: test_clean # clear the database before each acceptance test run
|
|||||||
|
|
||||||
test_clean:
|
test_clean:
|
||||||
$(DOCKER_COMPOSE) down -t 0
|
$(DOCKER_COMPOSE) down -t 0
|
||||||
|
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)
|
||||||
|
|
||||||
.PHONY: clean test test_unit test_acceptance test_clean build publish
|
.PHONY: clean test test_unit test_acceptance test_clean build publish
|
||||||
|
|||||||
@@ -7,17 +7,11 @@ version: "2"
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
test_unit:
|
test_unit:
|
||||||
image: node:6.13.0
|
image: quay.io/sharelatex/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
working_dir: /app
|
|
||||||
entrypoint: npm run test:unit:_run
|
entrypoint: npm run test:unit:_run
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
image: node:6.13.0
|
image: quay.io/sharelatex/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
working_dir: /app
|
|
||||||
environment:
|
environment:
|
||||||
REDIS_HOST: redis
|
REDIS_HOST: redis
|
||||||
MONGO_HOST: mongo
|
MONGO_HOST: mongo
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ services:
|
|||||||
entrypoint: npm run test:unit
|
entrypoint: npm run test:unit
|
||||||
|
|
||||||
test_acceptance:
|
test_acceptance:
|
||||||
image: node:6.13.0
|
build: .
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
working_dir: /app
|
working_dir: /app
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
/bin/sh
|
/bin/sh
|
||||||
wget -qO- https://get.docker.com/ | sh
|
wget -qO- https://get.docker.com/ | sh
|
||||||
apt-get install poppler-utils vim ghostscript --yes
|
apt-get install poppler-utils ghostscript --yes
|
||||||
npm rebuild
|
npm rebuild
|
||||||
|
usermod -aG docker app
|
||||||
|
|
||||||
|
touch /var/run/docker.sock
|
||||||
|
chown root:docker /var/run/docker.sock
|
||||||
|
|||||||
Reference in New Issue
Block a user