Skip to content

Commit 40c8f74

Browse files
authored
Merge pull request #1324 from okorach:docker-release
Docker-release
2 parents 380f033 + 7435399 commit 40c8f74

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ For more about what is exported and imported by `sonar-config` please see the [s
316316

317317
Starting from version 3.4 `sonar-tools` is available as a docker image. Here is how to use the docker version:
318318
```
319-
docker pull sonar-tools:latest
319+
docker pull olivierkorach/sonar-tools:latest
320320
# Run `docker run sonar-tools` followed by your usual sonar-tools command with its parameters, and example below for sonar-loc
321321
docker run --rm sonar-tools sonar-loc -u <YOUR_SONAR_URL> -t <YOUR_SONAR_TOKEN> <parameters>
322322

deploy.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ while [ $# -ne 0 ]; do
3434
pypi)
3535
release=1
3636
;;
37+
dockerhub)
38+
release_docker=1
39+
;;
3740
*)
3841
;;
3942
esac
@@ -48,7 +51,7 @@ python3 setup.py bdist_wheel
4851
pip install --upgrade --force-reinstall dist/sonar_tools-*-py3-*.whl
4952

5053
if [ "$build_image" == "1" ]; then
51-
docker build -t sonar-tools:latest .
54+
docker build -t olivierkorach/sonar-tools:3.4 -t olivierkorach/sonar-tools:latest -f snapshot.Dockerfile .
5255
fi
5356

5457
if [ "$build_docs" == "1" ]; then
@@ -63,4 +66,8 @@ if [ "$release" = "1" ]; then
6366
if [ "$confirm" = "y" ]; then
6467
python3 -m twine upload dist/sonar_tools-*-py3-*.whl
6568
fi
69+
fi
70+
71+
if [ "$release_docker" = "1" ]; then
72+
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-tools:3.4 -t olivierkorach/sonar-tools:latest -f release.Dockerfile .
6673
fi

release.Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM alpine:3.20.3
2+
LABEL maintainer="[email protected]"
3+
ENV IN_DOCKER="Yes"
4+
5+
ARG USERNAME=sonar
6+
ARG USER_UID=1000
7+
ARG GROUPNAME=sonar
8+
9+
# Create the user
10+
RUN addgroup -S ${GROUPNAME} && adduser -u ${USER_UID} -S ${USERNAME} -G ${GROUPNAME}
11+
12+
# Install python/pip
13+
ENV PYTHONUNBUFFERED=1
14+
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
15+
16+
# create a virtual environment and add it to PATH so that it is
17+
# applied for all future RUN and CMD calls
18+
ENV VIRTUAL_ENV=/opt/venv
19+
RUN python3 -m venv ${VIRTUAL_ENV}
20+
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
21+
22+
WORKDIR /opt/sonar-tools
23+
24+
COPY ./sonar sonar
25+
COPY ./requirements.txt .
26+
COPY ./cli cli
27+
COPY ./setup.py .
28+
COPY ./sonar-tools .
29+
COPY ./README.md .
30+
COPY ./LICENSE .
31+
COPY ./sonar/audit sonar/audit
32+
33+
RUN pip install --upgrade pip \
34+
&& pip install sonar-tools==3.4
35+
36+
USER ${USERNAME}
37+
WORKDIR /home/${USERNAME}
38+
39+
CMD [ "sonar-tools" ]
File renamed without changes.

test/test_migration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __test_config_cmd(arguments: list[str]) -> None:
4747
assert util.file_not_empty(outputfile)
4848
util.clean(outputfile)
4949

50+
5051
def test_migration_help() -> None:
5152
"""test_migration_help"""
5253
util.clean(util.JSON_FILE)

0 commit comments

Comments
 (0)