jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
8.2k stars 192 forks source link

Default initial Dockerfile unable to build #1953

Closed tclasen closed 4 months ago

tclasen commented 4 months ago

What happened?

The Dockerfile generated by devbox generate dockerfile doesn't seem to work on my box. I've seen this exact Dockerfile all over github so I'm not actually sure this is a problem with devbox itself, but maybe my local configuration or combination of tools.

$ docker --version

Docker version 24.0.6, build ed223bc

A possible solution would be:

diff --git a/Dockerfile b/Dockerfile
index dac5fa8..bf8e5a9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,7 +3,7 @@ FROM jetpackio/devbox:latest
 # Installing your devbox project
 WORKDIR /code
 USER root:root
-RUN mkdir /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
+RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
 USER ${DEVBOX_USER}:${DEVBOX_USER}
 COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
 COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock

Steps to reproduce

devbox init
echo "{}" > devbox.lock
devbox generate dockerfile
docker build .

Shell output

[+] Building 0.5s (7/10)                                                                                  docker:desktop-linux
 => [internal] load .dockerignore                                                                                         0.0s
 => => transferring context: 2B                                                                                           0.0s
 => [internal] load build definition from Dockerfile                                                                      0.0s
 => => transferring dockerfile: 434B                                                                                      0.0s
 => [internal] load metadata for docker.io/jetpackio/devbox:latest                                                        0.4s
 => [1/6] FROM docker.io/jetpackio/devbox:latest@sha256:4ca1d1c5a6cd7b1548b31426797b36831efa3cf340d7c120b4ea9ec8becf9ee2  0.0s
 => [internal] load build context                                                                                         0.0s
 => => transferring context: 425B                                                                                         0.0s
 => CACHED [2/6] WORKDIR /code                                                                                            0.0s
 => ERROR [3/6] RUN mkdir /code && chown devbox:devbox /code                                                              0.1s
------
 > [3/6] RUN mkdir /code && chown devbox:devbox /code:
0.093 mkdir: cannot create directory '/code': File exists
------
Dockerfile:6
--------------------
   4 |     WORKDIR /code
   5 |     USER root:root
   6 | >>> RUN mkdir /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
   7 |     USER ${DEVBOX_USER}:${DEVBOX_USER}
   8 |     COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code" did not complete successfully: exit code: 1

Command

generate

devbox.json

{
    "$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/0.10.3/.schema/devbox.schema.json",
    "packages": [],
    "shell": {
      "init_hook": [
        "echo 'Welcome to devbox!' > /dev/null"
      ],
      "scripts": {
        "test": [
          "echo \"Error: no test specified\" && exit 1"
        ]
      }
    }
  }

Devbox version

0.10.3

Nix version

zsh: command not found: nix

What system does this bug occur on?

macOS (Apple Silicon)

Debug logs

No response

s0rbus commented 4 months ago

This is same as I reported for https://github.com/jetpack-io/devbox/issues/1930 Welcome to the club ;-)

mohsenari commented 4 months ago

The PR that fixes this issue is merged. It will be included in the next version of Devbox release. Once the new release is out I will message here letting you know.

mohsenari commented 4 months ago

@tclasen With the release of devbox v0.10.4 this issue is resolved.