Skip to content

Commit 28d8dca

Browse files
fix: [APPSEC-327] run Docker formatter without root privileges (#282)
* fix: run Docker formatter without root privileges * style: remove trailing Dockerfile whitespace * fix: [APPSEC-327] pin CI to supported Java 11 runtime Added Java 11 setup step to CI workflow.
1 parent 975ba56 commit 28d8dca

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build
22

33
on: [pull_request]
44

5-
concurrency:
5+
concurrency:
66
group: ${{ github.workflow }}-${{ github.head_ref }}
77
cancel-in-progress: true
88

@@ -19,6 +19,12 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22+
- name: Set up Java 11
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: corretto
26+
java-version: '11'
27+
2228
- name: Test
2329
env:
2430
STREAM_KEY: ${{ secrets.STREAM_KEY }}

‎Dockerfile‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@ COPY settings.gradle .
1111
# Make gradlew executable
1212
RUN chmod +x gradlew
1313

14-
CMD ["sh", "-c", "./gradlew :spotlessApply"]
14+
RUN yum install -y shadow-utils findutils && yum clean all \
15+
&& useradd --create-home --uid 1000 formatter \
16+
&& chown -R formatter:formatter /code
17+
18+
ENV GRADLE_USER_HOME=/tmp/gradle
19+
USER formatter
20+
21+
CMD ["sh", "-c", "./gradlew :spotlessApply"]

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ test_with_docker:
1212

1313
format_with_docker:
1414
docker build -t stream-chat-java-formatter . && \
15-
docker run -v $(PWD):/code stream-chat-java-formatter
15+
docker run --user $$(id -u):$$(id -g) -v $(PWD):/code stream-chat-java-formatter

0 commit comments

Comments
 (0)