diff --git a/Dockerfile b/Dockerfile index a1afbe97852b6b08e2c810b81e42f5783c9360ec..e0a848177f43f6f228fc55570f773a2ad71b8582 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,18 @@ COPY package*.json ./ RUN npm install COPY . . -# Stage 2: Final Image for running the server +# Stage 2: Image for checking the linting +FROM base as lint +RUN npm install gts +CMD ["npm", "run", "lint"] + +# Stage 3: Image for running the server FROM base as server EXPOSE 3000 ENV DATA_DIRECTORY=/data CMD ["npm", "run", "start"] -# Stage 3: Final Image for running the tests +# Stage 4: Image for running the tests FROM base as test ENV DATA_DIRECTORY=/tests/data CMD ["npm", "run", "test"] diff --git a/Jenkinsfile b/Jenkinsfile index 14b2b557d4461e6235a48088e5cd75001771d94d..c43c3f818486801541f26d41f4a9635fdc2039c6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,7 +55,14 @@ pipeline { userRemoteConfigs: [[refspec: '${GERRIT_REFSPEC}', url: 'https://${JAMI_GERRIT_URL}/jami-plugins-store']]] } } - + stage('lint') { + steps { + script { + docker.build("jami-plugins-store:${env.BUILD_ID}", "--target lint .") + sh "docker run -t --rm jami-plugins-store:${env.BUILD_ID}" + } + } + } stage('test') { steps { script { diff --git a/README.md b/README.md index cff0f439b62e225892ada8175a6c3a6016a53c45..46c1eae54580580d722b36c1e7df762010e7a025 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ To install Docker please read this manual: https://docs.docker.com/engine/instal The Docker needs a data directory to store the plugins. You need a /data/ folder in your repo. The API will look for the plugins in this folder. This is a temporary situation until we have a database implemented. +## Run the server in a docker container + Build a docker image: `docker build -t server-image --target server .` @@ -82,7 +84,7 @@ Run the docker container: To stop the container do CTRL + C in the terminal. -To run tests in the docker container +## To run tests in the docker container Build the test image: @@ -92,6 +94,16 @@ Run the test image: `docker run test-image` +## To check if the code has been linted correctly in the docker container + +Build the lint image: + +`docker build -t lint-image --target lint .` + +Run the lint image: + +`docker run lint-image` + # Linting via pre-commit hook Set up the pre-commit hook: