Skip to content

Commit

Permalink
Switch to non-root user for Android SDK Flutter Docker Image
Browse files Browse the repository at this point in the history
android_sdk_flutter/Dockerfile
  • Loading branch information
crazyuploader committed Sep 24, 2024
1 parent 1dca6fc commit ce3938b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions android_sdk_flutter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@ ARG DEBIAN_FRONTEND=noninteractive
ENV TERM=xterm-256color

# Environment Variables
ENV FLUTTER_HOME /opt/flutter
ENV PATH ${PATH}:${FLUTTER_HOME}/bin
ENV FLUTTER_HOME=/opt/flutter
ENV PATH=${PATH}:${FLUTTER_HOME}/bin

# Getting Flutter stable from GitHub source https://github.com/flutter/flutter.git
RUN git clone --depth=1 https://github.com/flutter/flutter.git -b stable ${FLUTTER_HOME} && \
flutter doctor
RUN git clone --depth=1 https://github.com/flutter/flutter.git -b stable ${FLUTTER_HOME}

# Create a new non-root user
RUN useradd -m -s /bin/bash worker

# Change the ownership of the /opt/android-sdk & /opt/flutter directory
RUN chown -R worker:worker /opt/android-sdk && \
chown -R worker:worker ${FLUTTER_HOME}

# Set the new user as the active user
USER worker

# Run flutter doctor command
RUN flutter doctor

CMD ["bash"]

0 comments on commit ce3938b

Please sign in to comment.