Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dockerfiles/dut: fix --chown option #1256

Conversation

Bastian-Krause
Copy link
Member

Description
The docker docs contain [1] these COPY forms:

COPY [--chown=<user>:<group>] [--chmod=<perms>] <src>... <dest>
COPY [--chown=<user>:<group>] [--chmod=<perms>] ["<src>",... "<dest>"]

Arguments within [ ] are optional. The square brackets are not meant to be part of the actual instruction.

The docker docs [1] mention that "[e]ach may contain wildcards and matching will be done using Go’s filepath.Match rules". Go’s filepath.Match [2] interprets terms in square brackets as a character class. [--chown=root:root] must have been interpreted as a valid character class until recently. A couple of days ago, building the "dut" service started failing:

  Building dut
  #0 building with "default" instance using docker driver

  #1 [internal] load build definition from Dockerfile
  #1 transferring dockerfile: 924B done
  #1 DONE 0.0s

  #2 [internal] load .dockerignore
  #2 transferring context: 2B done
  #2 DONE 0.0s

  #3 [internal] load metadata for docker.io/library/debian:bookworm-slim
  #3 DONE 0.1s

  #4 [1/4] FROM docker.io/library/debian:bookworm-slim@sha256:89468107e4c2b9fdea2f15fc582bf92c25aa4296a661ca0202f7ea2f4fc3f48c
  #4 CACHED

  #5 [internal] load build context
  #5 transferring context: 56B done
  #5 ERROR: error from sender: invalid includepatterns: []: syntax error in pattern

Fix this by dropping the accidental square brackets around the --chown option.

[1] https://docs.docker.com/engine/reference/builder/#copy
[2] https://pkg.go.dev/path/filepath#Match

Checklist

  • PR has been tested

Fixes #540

The docker docs contain [1] these COPY forms:

  COPY [--chown=<user>:<group>] [--chmod=<perms>] <src>... <dest>
  COPY [--chown=<user>:<group>] [--chmod=<perms>] ["<src>",... "<dest>"]

Arguments within [ ] are optional. The square brackets are not meant to
be part of the actual instruction.

The docker docs [1] mention that "[e]ach <src> may contain wildcards and
matching will be done using Go’s filepath.Match rules". Go’s
filepath.Match [2] interprets terms in square brackets as a character
class. "[--chown=root:root]" must have been interpreted as a valid
character class until recently. A couple of days ago, building the "dut"
service started failing:

  Building dut
  #0 building with "default" instance using docker driver

  #1 [internal] load build definition from Dockerfile
  #1 transferring dockerfile: 924B done
  #1 DONE 0.0s

  #2 [internal] load .dockerignore
  #2 transferring context: 2B done
  #2 DONE 0.0s

  #3 [internal] load metadata for docker.io/library/debian:bookworm-slim
  #3 DONE 0.1s

  #4 [1/4] FROM docker.io/library/debian:bookworm-slim@sha256:89468107e4c2b9fdea2f15fc582bf92c25aa4296a661ca0202f7ea2f4fc3f48c
  #4 CACHED

  #5 [internal] load build context
  #5 transferring context: 56B done
  #5 ERROR: error from sender: invalid includepatterns: []: syntax error in pattern

Fix this by dropping the accidental square brackets around the --chown
option.

[1] https://docs.docker.com/engine/reference/builder/#copy
[2] https://pkg.go.dev/path/filepath#Match

Signed-off-by: Bastian Krause <[email protected]>
@Bastian-Krause Bastian-Krause force-pushed the bst/docker-invalid-includepatterns branch from c126bfd to 0523400 Compare August 7, 2023 10:55
@codecov
Copy link

codecov bot commented Aug 7, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (b0fe8dc) 62.9% compared to head (0523400) 62.9%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1256   +/-   ##
======================================
  Coverage    62.9%   62.9%           
======================================
  Files         161     161           
  Lines       11861   11861           
======================================
  Hits         7469    7469           
  Misses       4392    4392           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Bastian-Krause Bastian-Krause added the Pick to stable Needs a pick to the stable branch label Aug 7, 2023
@Bastian-Krause Bastian-Krause added this to the v23.1 milestone Aug 7, 2023
@Emantor Emantor merged commit 2bfba1a into labgrid-project:master Aug 7, 2023
@Bastian-Krause Bastian-Krause deleted the bst/docker-invalid-includepatterns branch August 8, 2023 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Pick to stable Needs a pick to the stable branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants