Browse Source

switch to non-root user

Fabian Peter Hammerle 2 years ago
parent
commit
f9fe754d19
2 changed files with 17 additions and 3 deletions
  1. 6 3
      Dockerfile
  2. 11 0
      README.md

+ 6 - 3
Dockerfile

@@ -11,10 +11,13 @@ FROM docker.io/alpine:3.15.0
 
 # https://web.archive.org/web/20220220103519/https://github.com/hadolint/hadolint/wiki/DL4006
 SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
+ARG TOIT_VERSION=1.18.2
 # hadolint ignore=DL3018
 RUN apk add --no-cache ca-certificates curl \
-    && curl https://archive.toit.io/cli/v1.18.2/linux \
+    && curl https://archive.toit.io/cli/v${TOIT_VERSION}/linux \
         | tar -xvzf - -C /usr/local/bin \
-    && apk del ca-certificates curl
+    && apk del ca-certificates curl \
+    && adduser -u 1000 -D toit
 
-# TODO change user
+USER toit
+CMD ["toit", "--help"]

+ 11 - 0
README.md

@@ -0,0 +1,11 @@
+```sh
+$ podman build --format docker -t toit .
+# host network for redirect back after login at
+# https://auth.toit.io/oauth/authorize?[...]?redirect_uri=http://localhost/[...]
+$ podman run --rm -it -v toit_home:/home/toit \
+    --network host toit \
+    toit device info
+$ podman run --rm -it -v toit_home:/home/toit \
+    --device /dev/ttyUSB0:/dev/ttyUSB0 --group-add keep-groups toit \
+    toit serial monitor
+```