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

Dockerfile Failing to Build on First Try #110

Closed
trufflethumb opened this issue Oct 18, 2023 · 1 comment · Fixed by #111
Closed

Dockerfile Failing to Build on First Try #110

trufflethumb opened this issue Oct 18, 2023 · 1 comment · Fixed by #111
Labels
bug Something isn't working

Comments

@trufflethumb
Copy link

trufflethumb commented Oct 18, 2023

Describe the bug

When the project doesn't have a Package.resolved. Docker Desktop on Mac fails to build the project on Dockerfile line 20:

...
RUN swift package resolve --skip-update \
        "$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)"
...

This is the build log:

[+] Building 3.0s (14/22)                                                                                           docker:desktop-linux
 => [app internal] load .dockerignore                                                                                               0.0s
 => => transferring context: 58B                                                                                                    0.0s
 => [app internal] load build definition from Dockerfile                                                                            0.0s
 => => transferring dockerfile: 3.26kB                                                                                              0.0s
 => [app internal] load metadata for docker.io/library/swift:5.9-jammy-slim                                                         2.6s
 => [app internal] load metadata for docker.io/library/swift:5.9-jammy                                                              2.4s
 => [app build  1/12] FROM docker.io/library/swift:5.9-jammy@sha256:a13d1eff9d1639c967c2c1f28740328f57cde4caaf979d07e86811cbaefdd8  0.0s
 => [app internal] load build context                                                                                               0.0s
 => => transferring context: 7.23kB                                                                                                 0.0s
 => [app stage-1 1/5] FROM docker.io/library/swift:5.9-jammy-slim@sha256:3beefe3ea2e54d49d11a4f9e54769268616e8ee5a26597dc0af15497c  0.0s
 => CACHED [app stage-1 2/5] RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true     && apt-get -q update    0.0s
 => CACHED [app stage-1 3/5] RUN useradd --user-group --create-home --system --skel /dev/null --home-dir /app vapor                 0.0s
 => CACHED [app stage-1 4/5] WORKDIR /app                                                                                           0.0s
 => CACHED [app build  2/12] RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true     && apt-get -q update    0.0s
 => CACHED [app build  3/12] WORKDIR /build                                                                                         0.0s
 => CACHED [app build  4/12] COPY ./Package.* ./                                                                                    0.0s
 => ERROR [app build  5/12] RUN swift package resolve --skip-update "$([ -f ./Package.resolved ] && echo "--force-resolved-version  0.4s
------                                                                                                                                   
 > [app build  5/12] RUN swift package resolve --skip-update "$([ -f ./Package.resolved ] && echo "--force-resolved-versions" || true)":
0.357 error: dependency '' was not found
------
failed to solve: process "/bin/sh -c swift package resolve --skip-update \"$([ -f ./Package.resolved ] && echo \"--force-resolved-versions\" || true)\"" did not complete successfully: exit code: 1

Note that the build goes beyond line 20 when Dockerfile reverts to the parent of commit 6563d51, which has the following line instead.

...
RUN swift package resolve --skip-update
...

To Reproduce

Steps to reproduce the behavior:

  1. Create a new Vapor App with vapor new my-dockerized-app and say no to everything when prompted.
  2. cd dockerized-app
  3. docker-compose build

Expected behavior

We should not see an error failing.

Environment

  • Vapor Framework version: from: "4.83.1", can't give exact because Package.resolved doesn't exist
  • Vapor Toolbox version: 18.7.4
  • OS version: macOS 13.4.1

Additional context

About the Docker I'm using on the Mac:
Docker Desktop 4.24.0 (122432)
Engine: 24.0.6
Compose: v2.22.0-desktop.2
Credential Helper: v0.7.0
Kubernetes: v1.27.2

@trufflethumb trufflethumb added the bug Something isn't working label Oct 18, 2023
@gwynne
Copy link
Member

gwynne commented Oct 18, 2023

Nice catch, thanks for the heads up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants