mirror of
https://github.com/Balshgit/sonar-scanner.git
synced 2025-09-10 22:40:41 +03:00
sonnar scanner 1.0.1
This commit is contained in:
commit
c5eca7f43d
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Pycharm
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Projects work files
|
||||||
|
logs/*
|
||||||
|
*.log
|
||||||
|
.scannerwork/
|
||||||
|
|
||||||
|
|
||||||
|
# Apple
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear on external disk
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
47
Dockerfile.sonarscanner
Normal file
47
Dockerfile.sonarscanner
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
FROM openjdk:12-jdk-alpine
|
||||||
|
|
||||||
|
# BEGIN alpine-specific
|
||||||
|
RUN apk add --no-cache curl grep sed unzip bash nano
|
||||||
|
RUN TERM=xterm
|
||||||
|
# END alpine-specific
|
||||||
|
|
||||||
|
# non-root user
|
||||||
|
ENV USER=sonarscanner
|
||||||
|
ENV UID=12345
|
||||||
|
ENV GID=23456
|
||||||
|
RUN addgroup --gid $GID sonarscanner
|
||||||
|
RUN adduser \
|
||||||
|
--disabled-password \
|
||||||
|
--gecos "" \
|
||||||
|
--ingroup "$USER" \
|
||||||
|
--no-create-home \
|
||||||
|
--uid "$UID" \
|
||||||
|
"$USER"
|
||||||
|
|
||||||
|
# Set timezone to CST
|
||||||
|
ENV TZ=Europe/Moscow
|
||||||
|
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||||
|
|
||||||
|
WORKDIR /usr/src
|
||||||
|
|
||||||
|
ARG SCANNER_VERSION=4.5.0.2216
|
||||||
|
ENV SCANNER_FILE=sonar-scanner-cli-${SCANNER_VERSION}-linux.zip
|
||||||
|
ENV SCANNER_EXPANDED_DIR=sonar-scanner-${SCANNER_VERSION}-linux
|
||||||
|
RUN curl --insecure -o ${SCANNER_FILE} \
|
||||||
|
-L https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/${SCANNER_FILE} && \
|
||||||
|
unzip -q ${SCANNER_FILE} && \
|
||||||
|
rm ${SCANNER_FILE} && \
|
||||||
|
mv ${SCANNER_EXPANDED_DIR} /usr/lib/sonar-scanner && \
|
||||||
|
ln -s /usr/lib/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner
|
||||||
|
|
||||||
|
ENV SONAR_RUNNER_HOME=/usr/lib/sonar-scanner
|
||||||
|
|
||||||
|
COPY sonar-scanner.properties /usr/lib/sonar-scanner/conf/sonar-scanner.properties
|
||||||
|
|
||||||
|
# ensure Sonar uses the provided Java for musl instead of a borked glibc one
|
||||||
|
RUN sed -i 's/use_embedded_jre=true/use_embedded_jre=false/g' /usr/lib/sonar-scanner/bin/sonar-scanner
|
||||||
|
|
||||||
|
# Separating ENTRYPOINT and CMD operations allows for core execution variables to
|
||||||
|
# be easily overridden by passing them in as part of the `docker run` command.
|
||||||
|
# This allows the default /usr/src base dir to be overridden by users as-needed.
|
||||||
|
#CMD ["sonar-scanner", "-Dsonar.projectBaseDir=/usr/src"]
|
29
README.md
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# HOW TO RUN
|
||||||
|
|
||||||
|
MOVE your python project ./code directory
|
||||||
|
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
|
# Results
|
||||||
|
|
||||||
|
Visit [http://localhost:9000/issues](http://localhost:9000/issues)
|
||||||
|
|
||||||
|
login: admin
|
||||||
|
password: password
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
|
||||||
|
Sonar logs can be found at log folder
|
||||||
|
|
||||||
|
# Run properties
|
||||||
|
|
||||||
|
Run properties can be changed in docker-compose command line
|
||||||
|
or something else
|
||||||
|
|
||||||
|
-Dsonar.host.url=http://sonarqube:9000 \
|
||||||
|
-Dsonar.jdbc.url=jdbc:h2:tcp://sonarqube/sonar \
|
||||||
|
-Dsonar.projectKey=MyProjectKey \
|
||||||
|
-Dsonar.projectName="My Project Name" \
|
||||||
|
-Dsonar.projectVersion=1 \
|
||||||
|
-Dsonar.projectBaseDir=/usr/src \
|
||||||
|
-Dsonar.sources=.
|
0
code/.gitkeep
Normal file
0
code/.gitkeep
Normal file
68
docker-compose.yml
Normal file
68
docker-compose.yml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
version: "3"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
sonarqube_data:
|
||||||
|
sonarqube_extensions:
|
||||||
|
sonarqube_logs:
|
||||||
|
pg_db:
|
||||||
|
pg_data:
|
||||||
|
elastic:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
sonarnet:
|
||||||
|
|
||||||
|
services:
|
||||||
|
sonarqube:
|
||||||
|
image: sonarqube:9.2.4-community
|
||||||
|
container_name: sonarqube
|
||||||
|
hostname: sonarqube
|
||||||
|
ports:
|
||||||
|
- "9000:9000"
|
||||||
|
environment:
|
||||||
|
- sonar.jdbc.username=sonar
|
||||||
|
- sonar.jdbc.password=sonar
|
||||||
|
- sonar.search.javaAdditionalOpts=-Dbootstrap.system_call_filter=false
|
||||||
|
volumes:
|
||||||
|
- sonarqube_data:/opt/sonarqube/data
|
||||||
|
- sonarqube_extensions:/opt/sonarqube/extensions
|
||||||
|
- ./logs:/opt/sonarqube/logs
|
||||||
|
networks:
|
||||||
|
- sonarnet
|
||||||
|
|
||||||
|
sonar_db:
|
||||||
|
image: postgres:12.9
|
||||||
|
container_name: sonar_db
|
||||||
|
hostname: db
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=sonar
|
||||||
|
- POSTGRES_PASSWORD=sonar
|
||||||
|
volumes:
|
||||||
|
- pg_db:/var/lib/postgresql
|
||||||
|
- pg_data:/var/lib/postgresql/data
|
||||||
|
ulimits:
|
||||||
|
nofile:
|
||||||
|
soft: 65536
|
||||||
|
hard: 65536
|
||||||
|
networks:
|
||||||
|
- sonarnet
|
||||||
|
|
||||||
|
sonar_scanner:
|
||||||
|
image: "sonar-scanner"
|
||||||
|
container_name: sonar_scanner
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile.sonarscanner
|
||||||
|
restart: on-failure
|
||||||
|
command: >
|
||||||
|
bash -c "echo 'start sleeping 30 sec' && sleep 30
|
||||||
|
&& echo 'Changing default passwords on sonar webpage'
|
||||||
|
&& curl -u admin:admin -X POST 'http://sonarqube:9000/api/users/change_password?login=admin&previousPassword=admin&password=password'
|
||||||
|
&& echo 'start sleeping 3 sec' && sleep 3
|
||||||
|
&& sonar-scanner -Dsonar.projectBaseDir=/usr/src"
|
||||||
|
depends_on:
|
||||||
|
- sonarqube
|
||||||
|
- sonar_db
|
||||||
|
networks:
|
||||||
|
- sonarnet
|
||||||
|
volumes:
|
||||||
|
- ./:/usr/src
|
37
sonar-scanner.properties
Normal file
37
sonar-scanner.properties
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# must be unique in a given SonarQube instance
|
||||||
|
sonar.projectKey=write_your_access_key_here
|
||||||
|
sonar.login=admin
|
||||||
|
sonar.password=password
|
||||||
|
|
||||||
|
#----- Default SonarQube server
|
||||||
|
sonar.host.url=http://sonarqube:9000
|
||||||
|
|
||||||
|
# --- optional properties ---
|
||||||
|
|
||||||
|
# defaults to project key
|
||||||
|
sonar.projectName=My project
|
||||||
|
# defaults to 'not provided'
|
||||||
|
sonar.projectVersion=1.0
|
||||||
|
|
||||||
|
# Path is relative to the sonar-project.properties file. Defaults to .
|
||||||
|
sonar.sources=./code
|
||||||
|
|
||||||
|
# Encoding of the source code. Default is default system encoding
|
||||||
|
sonar.sourceEncoding=UTF-8
|
||||||
|
|
||||||
|
#----- PostgreSQL
|
||||||
|
sonar.jdbc.url=jdbc:postgresql://sonar_db/sonar
|
||||||
|
|
||||||
|
#----- MySQL
|
||||||
|
#sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
|
||||||
|
|
||||||
|
#----- Oracle
|
||||||
|
#sonar.jdbc.url=jdbc:oracle:thin:@localhost/XE
|
||||||
|
|
||||||
|
#----- Microsoft SQLServer
|
||||||
|
#sonar.jdbc.url=jdbc:jtds:sqlserver://localhost/sonar;SelectMethod=Cursor
|
||||||
|
|
||||||
|
# H2 database from Docker Sonar container
|
||||||
|
#sonar.jdbc.url=jdbc:h2:tcp://sonarqube/sonar
|
||||||
|
|
||||||
|
sonar.projectBaseDir=/usr/src
|
8
sonarqube-init.sh
Normal file
8
sonarqube-init.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# per https://hub.docker.com/_/sonarqube
|
||||||
|
# to be executed before launching the app
|
||||||
|
|
||||||
|
sysctl -w vm.max_map_count=262144
|
||||||
|
sysctl -w fs.file-max=65536
|
||||||
|
ulimit -n 65536
|
||||||
|
ulimit -u 4096
|
Loading…
x
Reference in New Issue
Block a user