-
Notifications
You must be signed in to change notification settings - Fork 6
Extreme make over #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8dfe9e2
Initial commit.
filipesperandio 61aa0ab
Remove unecessary files
filipesperandio 7708991
Ignore .gradle and IntelliJ files
filipesperandio 6f85636
Use specific versions of sonarlint-core and sonarlit-client-api that …
filipesperandio 21d6b53
Override Sonarlint's classes to add CC's JsonReport
filipesperandio 02ac0f5
Give classpath priority to sonalint-core and sonarlint-client-api
filipesperandio 6bdd3d5
Keep license header
filipesperandio 174fecf
Move log messages to stderr
filipesperandio 115ebd1
Give app a proper name
filipesperandio c38ac39
Make app classes first priority on classpath - so we can override wha…
filipesperandio c634643
Docker setup
filipesperandio 359b560
Save a few MBs on docker image
filipesperandio 7e908b8
Optimize docker layers by caching project dependencies
filipesperandio 0de0f6f
Add sanitity check test
filipesperandio edb0c7e
Add CircleCI config
filipesperandio 27cec4a
Remove files for restructure
filipesperandio b361a70
Merge branch 'master' of github.com:filipesperandio/codeclimate-sonar…
filipesperandio f79ebde
Smarter ignores
filipesperandio d865975
Sonar needs writable directory on alaysis, keep it documented
filipesperandio 803d487
Fix problem with gradle base Docker image using its parent instead
filipesperandio 2e71f79
Remove extraline
filipesperandio f1ce0da
Bring back NOTICE/LICENSE/README
filipesperandio 7a323c5
Dockerfile improvements
filipesperandio 3c80af9
Improve dependencies caching
filipesperandio 77c76a0
Remove gradle wrapper
filipesperandio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,42 @@ | ||
FROM maven:3.3.9-jdk-8-alpine | ||
FROM java:8-jdk-alpine | ||
|
||
MAINTAINER Code Climate | ||
|
||
# Create user and app directory | ||
RUN adduser -u 9000 -D app | ||
COPY . /usr/src/app | ||
RUN chown -R app:app /usr/src/app | ||
VOLUME /code | ||
|
||
# Package the app with Maven | ||
WORKDIR /usr/src/app | ||
RUN mvn package | ||
# Increase Java memory limits | ||
ENV JAVA_OPTS="-XX:+UseParNewGC -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -Xss4096k" | ||
|
||
# Unzip the packaged app | ||
RUN mkdir /usr/src/app/dest | ||
RUN unzip /usr/src/app/target/sonarlint-cli-*.zip \ | ||
-d /usr/src/app/dest | ||
RUN cp -R /usr/src/app/dest/sonarlint-cli-*/* \ | ||
/usr/src/app/dest | ||
ENV GRADLE_VERSION=4.2.1 | ||
ENV GRADLE_HOME=/opt/gradle | ||
ENV GRADLE_FOLDER=$GRADLE_HOME | ||
ENV GRADLE_USER_HOME=$GRADLE_HOME | ||
ENV PATH=$GRADLE_HOME/bin:$PATH | ||
|
||
RUN mkdir -p $GRADLE_USER_HOME && \ | ||
chown -R app:app $GRADLE_USER_HOME && \ | ||
chmod g+s $GRADLE_USER_HOME && \ | ||
apk update && \ | ||
apk add --virtual .build-dependencies ca-certificates wget && \ | ||
update-ca-certificates && \ | ||
wget https://downloads.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip && \ | ||
unzip gradle-${GRADLE_VERSION}-bin.zip -d /opt && \ | ||
mv /opt/gradle-${GRADLE_VERSION}/* $GRADLE_HOME && \ | ||
rm -f gradle-${GRADLE_VERSION}-bin.zip && \ | ||
apk del .build-dependencies | ||
|
||
# Specify the /code volume | ||
# as needed by CC | ||
VOLUME /code | ||
WORKDIR /usr/src/app | ||
|
||
# Create a writeable directory for the code | ||
RUN mkdir -p /code-read-write | ||
RUN chown -R app:app /code-read-write | ||
RUN chmod -R 777 /code-read-write | ||
# Cache dependencies | ||
COPY build.gradle ./ | ||
RUN gradle infra | ||
|
||
# Increase Java memory limits | ||
ENV JAVA_OPTS="-XX:+UseParNewGC -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -Xss4096k" | ||
COPY . ./ | ||
RUN chown -R app:app ./ | ||
|
||
RUN gradle clean build -x test | ||
|
||
# Switch to app user, copy code to writable | ||
# directory, and run the engine | ||
USER app | ||
ENTRYPOINT [] | ||
WORKDIR /code-read-write | ||
CMD cp -R /code/* . && \ | ||
/usr/src/app/dest/bin/sonarlint \ | ||
--src 'src/main/**/*.java' | ||
WORKDIR /code | ||
CMD cp -R /code /tmp/ && /usr/src/app/build/codeclimate-sonar /tmp/code | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.PHONY: image test | ||
|
||
IMAGE_NAME ?= codeclimate/codeclimate-sonar-java | ||
|
||
image: | ||
docker build --rm -t $(IMAGE_NAME) . | ||
|
||
test: image | ||
docker run --rm -ti -w /usr/src/app -u root $(IMAGE_NAME) gradle clean test |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env sh | ||
|
||
BUILD_DIR=$(dirname $0) | ||
APP=$(find ${BUILD_DIR}/libs -name "codeclimate*.jar" | tr "\n" ":") | ||
LIBS=$(find ${BUILD_DIR}/libs -name "*.jar" | tr "\n" ":") | ||
CORE=$(find ${BUILD_DIR}/libs -name "sonarlint-core*.jar" -or -name "sonarlint-client-api*.jar" | tr "\n" ":") | ||
|
||
CODE_DIR=$1; shift | ||
|
||
java \ | ||
-cp ${APP}:${CORE}:${LIBS} \ | ||
-Djava.awt.headless=true \ | ||
-Dsonarlint.home="${BUILD_DIR}" \ | ||
-Dproject.home="${CODE_DIR}" \ | ||
-Dorg.freemarker.loggerLibrary=none \ | ||
cc.App --src "**/*.java" $@ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like sonarlint supports a
SONARLINT_USER_HOME
environment variable. Could that be used to redirect the tool's output to another directory, leaving the source code under analysis untouched in/code
?SonarSource/sonarlint-core@220729b#diff-fc98b7a351de15143748ac690d4fc601
Trying to find a way to avoid this
cp -R
workaround.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dblandin Didn't work. That reference seems outdated.
I think we can override it somewhere, but I would like to approach this in a separate PR as well. If it is OK for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: https://github.com/codeclimate/sonar-java/issues/20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me 👍