From 556f0dc49b8a13980c9abfad1bef11c5dca2a496 Mon Sep 17 00:00:00 2001 From: ivcosla Date: Fri, 5 Jul 2019 11:21:55 +0200 Subject: [PATCH] skywire docker image working --- .dockerignore | 6 ++++ docker/images/builder/Dockerfile | 25 ----------------- docker/images/builder/install.sh | 13 --------- docker/images/node/Dockerfile | 34 ++++++++++++++++++++--- docker/images/{builder => node}/update.sh | 3 +- 5 files changed, 38 insertions(+), 43 deletions(-) create mode 100644 .dockerignore delete mode 100644 docker/images/builder/Dockerfile delete mode 100755 docker/images/builder/install.sh rename docker/images/{builder => node}/update.sh (78%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..e589eea63c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +bin +skywire +ci_scripts +apps +integration diff --git a/docker/images/builder/Dockerfile b/docker/images/builder/Dockerfile deleted file mode 100644 index a40ca87198..0000000000 --- a/docker/images/builder/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -ARG base=golang:alpine - -FROM ${base} as devenv - -ARG CGO_ENABLED=0 -ENV CGO_ENABLED=${CGO_ENABLED} \ - GOOS=linux \ - GOARCH=amd64 \ - GO111MODULE=on - -COPY . skywire -WORKDIR skywire - -RUN ./docker/images/builder/update.sh -RUN ./docker/images/builder/install.sh -RUN apk add make - -RUN go build -mod=vendor -tags netgo -ldflags="-w -s" \ - -o skywire-node cmd/skywire-node/skywire-node.go &&\ - go build -mod=vendor -ldflags="-w -s" -o ./apps/skychat.v1.0 ./cmd/apps/skychat &&\ - go build -mod=vendor -ldflags="-w -s" -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld &&\ - go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy.v1.0 ./cmd/apps/therealproxy &&\ - go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client &&\ - go build -mod=vendor -ldflags="-w -s" -o ./apps/SSH.v1.0 ./cmd/apps/therealssh &&\ - go build -mod=vendor -ldflags="-w -s" -o ./apps/SSH-client.v1.0 ./cmd/apps/therealssh-client diff --git a/docker/images/builder/install.sh b/docker/images/builder/install.sh deleted file mode 100755 index bcd6e75784..0000000000 --- a/docker/images/builder/install.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -if type apt > /dev/null; then - apt update - apt upgrade -y - apt install -y ca-certificates iproute2 iputils-ping redis-server supervisor - - # rm -rf /var/lib/apt/lists/* -fi - -if type apk > /dev/null; then - apk add --no-cache redis supervisor -fi diff --git a/docker/images/node/Dockerfile b/docker/images/node/Dockerfile index 4280f925fc..efa78efa5a 100644 --- a/docker/images/node/Dockerfile +++ b/docker/images/node/Dockerfile @@ -1,12 +1,38 @@ -ARG builder=node-builder +# Builder +# ARG builder_base=golang:alpine ARG base=alpine +FROM golang:alpine as builder -FROM ${builder} as builder +ARG CGO_ENABLED=0 +ENV CGO_ENABLED=${CGO_ENABLED} \ + GOOS=linux \ + GOARCH=amd64 \ + GO111MODULE=on -FROM ${base} as base +COPY . skywire + +WORKDIR skywire + +RUN go build -mod=vendor -tags netgo -ldflags="-w -s" \ + -o skywire-node cmd/skywire-node/skywire-node.go &&\ + go build -mod=vendor -ldflags="-w -s" -o ./apps/skychat.v1.0 ./cmd/apps/skychat &&\ + go build -mod=vendor -ldflags="-w -s" -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld &&\ + go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy.v1.0 ./cmd/apps/therealproxy &&\ + go build -mod=vendor -ldflags="-w -s" -o ./apps/socksproxy-client.v1.0 ./cmd/apps/therealproxy-client &&\ + go build -mod=vendor -ldflags="-w -s" -o ./apps/SSH.v1.0 ./cmd/apps/therealssh &&\ + go build -mod=vendor -ldflags="-w -s" -o ./apps/SSH-client.v1.0 ./cmd/apps/therealssh-client + + +## Resulting image +FROM ${base} as node-runner COPY --from=builder /go/skywire/skywire-node skywire-node COPY --from=builder /go/skywire/apps bin/apps -COPY --from=builder /go/skywire/docker/images/builder/update.sh update.sh +COPY --from=builder /go/skywire/docker/images/node/update.sh update.sh + +RUN ./update.sh ENTRYPOINT [ "./skywire-node" ] + +# default target +FROM node-runner diff --git a/docker/images/builder/update.sh b/docker/images/node/update.sh similarity index 78% rename from docker/images/builder/update.sh rename to docker/images/node/update.sh index 692fbec110..8b78e26aee 100755 --- a/docker/images/builder/update.sh +++ b/docker/images/node/update.sh @@ -10,6 +10,7 @@ if type apk > /dev/null; then apk update apk upgrade - apk add --no-cache ca-certificates openssl + apk add --no-cache ca-certificates openssl iproute2 update-ca-certificates --fresh + apk add iproute2 fi