0

我无法构建将上传到 DockerHub/AWS EC2 的 docker 映像,该文件夹归 root 所有。docker install 按照官方 docker 文档的指示进行,hello-world 测试运行没有错误。我在这里关注帖子https://www.raywenderlich.com/1244870-deploying-kitura-with-docker-kubernetes-getting-started

Swift/Kitura 项目构建和运行没有错误。

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

运行的命令列表

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" ]

包.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")
  ]
)

输出

4

0 回答 0