0

I am unable to build the docker image which will be uploaded to DockerHub/AWS EC2, the folder is owned by root. The docker install is as directed on the official docker docs, the hello-world test runs without error. I am following the post here https://www.raywenderlich.com/1244870-deploying-kitura-with-docker-kubernetes-getting-started

The Swift/Kitura project builds and runs without error.

conor@lenovo:~/workspace/UserInstruction$ ls -la
total 56
drwxr-xr-x 7 conor conor 4096 Dec 11 16:15 .
drwxr-xr-x 7 conor conor 4096 Dec 11 09:52 ..
drwxr-xr-x 5 conor conor 4096 Dec 11 16:13 .build
drwxr-xr-x 5 root  root  4096 Dec 11 16:17 .build-ubuntu
-rw-r--r-- 1 conor conor  950 Dec 11 16:16 Dockerfile
-rwxr-xr-x 1 conor conor  876 Dec 10 08:49 Dockerfile-tools
drwxr-xr-x 8 conor conor 4096 Dec 10 11:46 .git
-rw-r--r-- 1 conor conor   53 Dec 10 08:25 .gitignore
-rw-r--r-- 1 conor conor 4144 Dec 11 16:16 Package.resolved
-rw-r--r-- 1 conor conor  716 Dec 11 16:16 Package.swift
-rw-r--r-- 1 conor conor   50 Dec 10 08:25 README.md
drwxr-xr-x 3 conor conor 4096 Dec 10 08:25 Sources
drwxr-xr-x 3 conor conor 4096 Dec 10 08:25 Tests


root@lenovo:~# ls -la /home/conor/workspace/UserInstruction/.build-ubuntu/
total 284
drwxr-xr-x  5 root  root    4096 Dec 11 16:17 .
drwxr-xr-x  7 conor conor   4096 Dec 11 16:15 ..
-rw-r--r--  1 root  root  142336 Dec 11 16:17 build.db
drwxr-x--- 17 root  root    4096 Dec 11 16:16 checkouts
-rw-r--r--  1 root  root    5283 Dec 11 16:16 dependencies-state.json
-rw-r--r--  1 root  root       2 Dec 11 16:16 regenerate-token
lrwxrwxrwx  1 root  root      28 Dec 11 16:17 release -> x86_64-unknown-linux/release
-rw-r--r--  1 root  root  114525 Dec 11 16:16 release.yaml
drwxr-x--- 17 root  root    4096 Dec 11 16:16 repositories
drwxr-x---  3 root  root    4096 Dec 11 16:16 x86_64-unknown-linux

swift --version
Swift version 5.1 (swift-5.1.2-RELEASE)
Target: x86_64-unknown-linux-gnu

List of Commands Run

swift build
docker build -t user-instructions-build -f Dockerfile-tools .
docker run -v $PWD:/swift-project -w /swift-project user-instructions-build /swift-utils/tools-utils.sh build release


conor@lenovo:~/workspace/UserInstruction$ docker build -t user-instructions-run .
error checking context: 'can't stat '/home/conor/workspace/UserInstruction/.build-ubuntu/checkouts''.

ls /home/conor/workspace/UserInstruction/.build-ubuntu/
build.db  checkouts  dependencies-state.json  regenerate-token  release  release.yaml  repositories  x86_64-unknown-linux

Dockerfile

FROM ibmcom/swift-ubuntu-runtime:4.1.0
MAINTAINER IBM Swift Engineering at IBM Cloud
LABEL Description="Template Dockerfile that extends the ibmcom/swift-ubuntu-runtime image."

# We can replace this port with what the user wants
EXPOSE 8080

# Default user if not provided
ARG bx_dev_user=root
ARG bx_dev_userid=1000

# Install system level packages
# RUN apt-get update && apt-get dist-upgrade -y

# Add utils files
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/run-utils.sh /swift-utils/run-utils.sh
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-docker/master/utils/common-utils.sh /swift-utils/common-utils.sh
RUN chmod -R 555 /swift-utils

# Create user if not root
RUN if [ $bx_dev_user != "root" ]; then useradd -ms /bin/bash -u $bx_dev_userid $bx_dev_user; fi

# Bundle application source & binaries
COPY . /swift-project

# Command to start Swift application
CMD [ "sh", "-c", "swift run" ]

Package.swift

// swift-tools-version:4.1.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  // 1
  name: "UserInstruction",
  dependencies: [
    // 2
    .package(url: "https://github.com/IBM-Swift/Kitura.git",
      .upToNextMajor(from: "2.0.0")),
    // 3
    .package(url: "https://github.com/IBM-Swift/HeliumLogger.git",
      .upToNextMajor(from: "1.0.0")),
    // 4
    .package(url: "https://github.com/IBM-Swift/Kitura-CouchDB.git",
      .upToNextMajor(from: "3.0.0"))
  ],
  //5
  targets: [
    .target(name: "UserInstruction",
      dependencies: ["Kitura" , "HeliumLogger", "CouchDB"],
      path: "Sources")
  ]
)

full output

Conor
  • 315
  • 2
  • 15
  • What are the access rights on the `checkout` file/dir in your build context (user, group and access mode)? – Zeitounator Dec 11 '19 at 16:54
  • `root@lenovo:~# ls -la /home/conor/workspace/UserInstruction/.build-ubuntu/ total 284 drwxr-xr-x 5 root root 4096 Dec 11 16:17 . drwxr-xr-x 7 conor conor 4096 Dec 11 16:15 .. -rw-r--r-- 1 root root 142336 Dec 11 16:17 build.db drwxr-x--- 17 root root 4096 Dec 11 16:16 checkouts` – Conor Dec 11 '19 at 17:02
  • Please add this to you question, not in comments. This is where user are looking for relevant info to help you out - your current user (i.e. conor as chown in your output in your question) does have the rights to `rx` the folder and therefore cannot send it to the engine in the build context. `sudo chmod 0755` or `sudo chown conor.conor` should fix your problem. – Zeitounator Dec 11 '19 at 17:23
  • Your host user doesn't have read permission on that `checkouts` directory. If you tried to `tar cvf something.tar .` you'd get a similar error (and in fact that's very close to what Docker is doing during that "checking context" phase). Running `sudo docker build ...` probably is reasonable here (since if you can `docker` anything you can almost trivially root the host). – David Maze Dec 12 '19 at 00:39
  • Thanks chmod -R 0755 .build-ubuntu worked – Conor Dec 12 '19 at 09:38

0 Answers0