Skip to content

Commit 8f886de

Browse files
committed
Fixes #1317
1 parent 3ab9252 commit 8f886de

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
FROM alpine:3.20.3
22
LABEL maintainer="[email protected]"
3+
ENV IN_DOCKER="Yes"
34

45
ARG USERNAME=sonar
56
ARG USER_UID=1000
@@ -33,7 +34,7 @@ RUN pip install --upgrade pip \
3334
&& pip install --no-cache-dir -r requirements.txt \
3435
&& pip install --no-cache-dir --upgrade pip setuptools wheel \
3536
&& python setup.py bdist_wheel \
36-
&& pip install dist/*-py3-*.whl --force-reinstall
37+
&& pip install dist/sonar_tools-*-py3-*.whl --force-reinstall
3738

3839
USER ${USERNAME}
3940
WORKDIR /home/${USERNAME}

cli/options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ def parse_and_check(parser: ArgumentParser, logger_name: str = None, verify_toke
191191
log.info("sonar-migration version %s", version.MIGRATION_TOOL_VERSION)
192192
else:
193193
log.info("sonar-tools version %s", version.PACKAGE_VERSION)
194+
if os.getenv("IN_DOCKER", "No") == "Yes":
195+
kwargs[URL] = kwargs[URL].replace("http://localhost", "http://host.docker.internal")
194196
if log.get_level() == log.DEBUG:
195197
sanitized_args = kwargs.copy()
196198
sanitized_args[TOKEN] = utilities.redacted_token(sanitized_args[TOKEN])

migration.Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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-migration
23+
24+
COPY ./sonar sonar
25+
COPY ./requirements.txt .
26+
COPY ./cli cli
27+
COPY ./setup_migration.py .
28+
COPY ./sonar_migration .
29+
COPY ./README.md .
30+
COPY ./LICENSE .
31+
COPY ./sonar/audit sonar/audit
32+
33+
# RUN pip install --upgrade pip \
34+
# && pip install --no-cache-dir -r requirements.txt \
35+
# && pip install --no-cache-dir --upgrade pip setuptools wheel \
36+
# && python setup-migration.py bdist_wheel \
37+
# && pip install dist/sonar_migration-py3-*.whl --force-reinstall
38+
39+
RUN pip install --upgrade pip
40+
RUN pip install --no-cache-dir -r requirements.txt
41+
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
42+
RUN python setup_migration.py bdist_wheel
43+
RUN pip install dist/sonar_migration-*-py3-*.whl --force-reinstall
44+
45+
USER ${USERNAME}
46+
WORKDIR /home/${USERNAME}
47+
48+
ENTRYPOINT ["sonar-migration"]

0 commit comments

Comments
 (0)