docker-cordova icon indicating copy to clipboard operation
docker-cordova copied to clipboard

Enable executing cordova as non-root

Open ooxi opened this issue 2 years ago • 1 comments

What is required to execute cordova as non root user? I want to mount my application and execute cordova on it, but all artifacts have root permission

ooxi avatar Aug 18 '23 08:08 ooxi

Thank you for raising issue. I tried a simple configuration to run the Docker image as non-root with the following configuration:

FROM beevelop/cordova

# Add a non-root user to run the container
RUN addgroup --gid 1001 bee && \
    adduser --uid 1001 --ingroup bee --home /home/bee --shell /bin/sh --disabled-password bee

# Set the user to run the container
USER bee

# Set the working directory
WORKDIR /home/bee
# running this with docker run -it bee bash
bee@1e81c3fe403f:~$ whoami
bee
bee@1e81c3fe403f:~$ cordova -v
? May Cordova anonymously report usage statistics to improve the tool over time? No

You have been opted out of telemetry. To change this, run: cordova telemetry on.
12.0.0 ([email protected])
bee@1e81c3fe403f:~$ cordova create foo
Creating a new cordova project.
bee@1e81c3fe403f:~$ cd foo/
bee@1e81c3fe403f:~/foo$ ls
config.xml  package.json  www
bee@1e81c3fe403f:~/foo$ cordova platform add android
Using cordova-fetch for cordova-android
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms/android
        Package: io.cordova.hellocordova
        Name: HelloCordova
        Activity: MainActivity
        Android Target SDK: android-33
        Android Compile SDK: 33
Subproject Path: CordovaLib
Subproject Path: app
Android project created with [email protected]
bee@1e81c3fe403f:~/foo$ cordova build android
Checking Java JDK and Android SDK versions
[...]
BUILD SUCCESSFUL in 1m 49s
50 actionable tasks: 50 executed

Are you able to use a custom image with the above instructions? That might resolve the wrong file permissions.

beevelop avatar Oct 16 '23 19:10 beevelop