Просмотр исходного кода

Merge branch 'master' of https://github.com/porter-dev/porter into main

sunguroku 5 лет назад
Родитель
Сommit
8edf147eb6
11 измененных файлов с 133 добавлено и 42 удалено
  1. 11 28
      .github/workflows/release.yaml
  2. 7 8
      README.md
  3. 18 0
      build/Dockerfile.osx
  4. 17 0
      build/Dockerfile.win
  5. 3 0
      cli/cmd/github/release.go
  6. 32 5
      cli/cmd/server.go
  7. 1 1
      cli/cmd/version.go
  8. 15 0
      cmd/app/main.go
  9. 3 0
      go.sum
  10. 13 0
      scripts/build/osx.sh
  11. 13 0
      scripts/build/win.sh

+ 11 - 28
.github/workflows/release.yaml

@@ -92,6 +92,7 @@ jobs:
         env:
           GOOS: linux
           GOARCH: amd64
+          CGO_ENABLED: 1
       # Note: we have to zip all binaries before uploading them as artifacts --
       # without this step, the binaries will be uploaded but the file metadata will
       # be listed as plaintext after downloading the artifact in a later step
@@ -103,36 +104,18 @@ jobs:
           zip --junk-paths ./release/linux/porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./porter
           zip --junk-paths ./release/linux/portersvr_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./portersvr
           zip --junk-paths ./release/linux/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Linux_x86_64.zip ./docker-credential-porter
-      - name: Build Darwin binaries
+      - name: Build and zip Darwin binaries
         run: |
-          go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=${{steps.tag_name.outputs.tag}}'" -a -tags cli -o ./porter ./cli &
-          go build -ldflags="-w -s -X 'main.Version=${{steps.tag_name.outputs.tag}}'" -a -o ./docker-credential-porter ./cmd/docker-credential-porter/ &
-          go build -ldflags="-w -s" -a -o ./portersvr ./cmd/app/ &
-          wait
-        env:
-          GOOS: darwin
-          GOARCH: amd64
-      - name: Zip Darwin binaries
-        run: |
-          mkdir -p ./release/darwin
-          zip --junk-paths ./release/darwin/UNSIGNED_porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip ./porter
-          zip --junk-paths ./release/darwin/UNSIGNED_portersvr_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip ./portersvr
-          zip --junk-paths ./release/darwin/UNSIGNED_docker-credential-porter_${{steps.tag_name.outputs.tag}}_Darwin_x86_64.zip ./docker-credential-porter
-      - name: Build Windows binaries
-        run: |
-          go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=${{steps.tag_name.outputs.tag}}'" -a -tags cli -o ./porter.exe ./cli &
-          go build -ldflags="-w -s -X 'main.Version=${{steps.tag_name.outputs.tag}}'" -a -o ./docker-credential-porter.exe ./cmd/docker-credential-porter/ &
-          go build -ldflags="-w -s" -a -o ./portersvr.exe ./cmd/app/ &
-          wait
-        env:
-          GOOS: windows
-          GOARCH: amd64
-      - name: Zip Windows binaries
+          docker build . --file ./build/Dockerfile.osx -t osx
+          docker run \
+          --mount type=bind,source="$(pwd)"/release,target=/release \
+          osx:latest ${{steps.tag_name.outputs.tag}}
+      - name: Build and zip Windows binaries
         run: |
-          mkdir -p ./release/windows
-          zip --junk-paths ./release/windows/porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip ./porter.exe
-          zip --junk-paths ./release/windows/portersvr_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip ./portersvr.exe
-          zip --junk-paths ./release/windows/docker-credential-porter_${{steps.tag_name.outputs.tag}}_Windows_x86_64.zip ./docker-credential-porter.exe
+          docker build . --file ./build/Dockerfile.win -t win
+          docker run \
+          --mount type=bind,source="$(pwd)"/release,target=/release \
+          win:latest ${{steps.tag_name.outputs.tag}}
       - name: Upload binaries
         uses: actions/upload-artifact@v2
         with:

+ 7 - 8
README.md

@@ -3,15 +3,15 @@
 
 **Porter is a Kubernetes-powered PaaS that runs in your own cloud provider.** Porter brings the Heroku experience to Kubernetes without compromising its flexibility. Get started on Porter without the overhead of DevOps and fully customize your infra later when you need to.
 
-![Provisioning View](https://user-images.githubusercontent.com/65516095/103712142-09e34280-4f87-11eb-9272-a35805544fd0.png)
+![Provisioning View](https://user-images.githubusercontent.com/22849518/104234811-fe2dcb00-5421-11eb-9ce3-c0ebefc37476.png)
 
 
 ## Why Porter?
 ### A PaaS that grows with your applications
 
-Traditional PaaS's like Heroku are great at minimizing unnecessary DevOps work but don't offer enough flexibility as your applications scale. Custom network rules, resource constraints, and cost are common reasons developers move their application off Heroku beyond a certain scale. 
+A traditional PaaS like Heroku is great for minimizing unnecessary DevOps work but doesn't offer enough flexibility as your applications grow. Custom network rules, resource constraints, and cost are common reasons developers move their applications off Heroku beyond a certain scale. 
 
-Porter brings the simplicity of traditional PaaS's to your own cloud provider while preserving the configurability of Kubernetes. It's built on top of a popular Kubernetes framework called Helm and is compatible with standard Kubernetes management tools like `kubectl`, preparing your infra for mature DevOps work from day 1.
+Porter brings the simplicity of a traditional PaaS to your own cloud provider while preserving the configurability of Kubernetes. Porter is built on top of a popular Kubernetes package manager called Helm and is compatible with standard Kubernetes management tools like `kubectl`, preparing your infra for mature DevOps work from day one.
 
 ![image](https://user-images.githubusercontent.com/65516095/103713478-71e75800-4f8a-11eb-915f-adee9d4f5bf7.png)
 
@@ -25,19 +25,18 @@ Porter brings the simplicity of traditional PaaS's to your own cloud provider wh
 - Simple deploy of any public or private Docker image
 
 - Heroku-like GUI to monitor application status, logs, and history
-- Marketplace for 1-click add-on's (e.g. MongoDB, Redis, PostgreSQL)
-- Application rollback to previous deploy versions
+- Marketplace for one click add-ons (e.g. MongoDB, Redis, PostgreSQL)
+- Application rollback to previously deployed versions
 - Native CI/CD with buildpacks (Coming Soon)
 
 ### DevOps Mode
 For those who are familiar with Kubernetes and Helm:
 
-- Visualize, deploy and configure Helm charts via the GUI
-
+- Connect to existing Kubernetes clusters that are not provisioned by Porter
+- Visualize, deploy, and configure Helm charts via the GUI
 - User-generated [form overlays](https://docs.getporter.dev/docs/porter-templates) for managing `values.yaml`
 - In-depth view of releases, including revision histories and component graphs
 - Rollback/update of existing releases, including editing of raw `values.yaml`
-- Connect to existing Kubernetes clusters that are not provisioned by Porter
 
 ![Graph View](https://user-images.githubusercontent.com/22849518/101073320-43322800-356d-11eb-9b69-a68bd951992e.png)
 

+ 18 - 0
build/Dockerfile.osx

@@ -0,0 +1,18 @@
+ARG GO_VERSION=1.13.15
+
+FROM dockercore/golang-cross:${GO_VERSION}
+
+RUN apt-get update && apt-get install -y zip unzip
+
+WORKDIR /go/src/github.com/docker/cli
+COPY    . .
+
+ENV CGO_ENABLED 1
+ENV GOOS darwin
+ENV GOARCH amd64
+ENV CC o64-clang
+ENV CXX o64-clang++
+
+RUN chmod +x ./scripts/build/osx.sh
+
+ENTRYPOINT [ "./scripts/build/osx.sh" ]

+ 17 - 0
build/Dockerfile.win

@@ -0,0 +1,17 @@
+ARG GO_VERSION=1.13.15
+
+FROM	dockercore/golang-cross:${GO_VERSION}
+
+RUN apt-get update && apt-get install -y zip unzip
+
+WORKDIR /go/src/github.com/docker/cli
+COPY    . .
+
+ENV CC x86_64-w64-mingw32-gcc
+ENV CGO_ENABLED 1
+ENV GOOS windows 
+ENV GOARCH amd64
+
+RUN chmod +x ./scripts/build/win.sh
+
+ENTRYPOINT [ "./scripts/build/win.sh" ]

+ 3 - 0
cli/cmd/github/release.go

@@ -240,6 +240,9 @@ func (z *ZIPReleaseGetter) unzipToDir() error {
 			continue
 		}
 
+		// delete file if exists
+		os.Remove(fpath)
+
 		// Make File
 		if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil {
 			return err

+ 32 - 5
cli/cmd/server.go

@@ -175,10 +175,26 @@ func startLocal(
 	staticFilePath := filepath.Join(home, ".porter", "static")
 
 	if _, err := os.Stat(cmdPath); os.IsNotExist(err) {
-		err := downloadLatestReleases(porterDir)
+		err := downloadMatchingRelease(porterDir)
 
 		if err != nil {
-			color.New(color.FgRed).Println("Failed:", err.Error())
+			color.New(color.FgRed).Println("Failed to download server binary:", err.Error())
+			os.Exit(1)
+		}
+	}
+
+	// otherwise, check the version flag of the binary
+	cmdVersionPorter := exec.Command(cmdPath)
+	writer := &versionWriter{}
+	cmdVersionPorter.Stdout = writer
+
+	err := cmdVersionPorter.Run()
+
+	if err != nil || writer.Version != Version {
+		err := downloadMatchingRelease(porterDir)
+
+		if err != nil {
+			color.New(color.FgRed).Println("Failed to download server binary:", err.Error())
 			os.Exit(1)
 		}
 	}
@@ -190,12 +206,13 @@ func startLocal(
 		"SQL_LITE=true",
 		"SQL_LITE_PATH=" + sqlLitePath,
 		"STATIC_FILE_PATH=" + staticFilePath,
+		"REDIS_ENABLED=false",
 	}...)
 
 	cmdPorter.Stdout = os.Stdout
 	cmdPorter.Stderr = os.Stderr
 
-	err := cmdPorter.Run()
+	err = cmdPorter.Run()
 
 	if err != nil {
 		color.New(color.FgRed).Println("Failed:", err.Error())
@@ -225,7 +242,7 @@ func stopDocker() error {
 	return nil
 }
 
-func downloadLatestReleases(porterDir string) error {
+func downloadMatchingRelease(porterDir string) error {
 	z := &github.ZIPReleaseGetter{
 		AssetName:           "portersvr",
 		AssetFolderDest:     porterDir,
@@ -236,7 +253,7 @@ func downloadLatestReleases(porterDir string) error {
 		IsPlatformDependent: true,
 	}
 
-	err := z.GetLatestRelease()
+	err := z.GetRelease(Version)
 
 	if err != nil {
 		return err
@@ -254,3 +271,13 @@ func downloadLatestReleases(porterDir string) error {
 
 	return zStatic.GetLatestRelease()
 }
+
+type versionWriter struct {
+	Version string
+}
+
+func (v *versionWriter) Write(p []byte) (n int, err error) {
+	v.Version = string(p)
+
+	return len(p), nil
+}

+ 1 - 1
cli/cmd/version.go

@@ -7,7 +7,7 @@ import (
 )
 
 // Version will be linked by an ldflag during build
-var Version string = "dev"
+var Version string = "v0.1.0-beta.3.1"
 
 var versionCmd = &cobra.Command{
 	Use:     "version",

+ 15 - 0
cmd/app/main.go

@@ -1,9 +1,11 @@
 package main
 
 import (
+	"flag"
 	"fmt"
 	"log"
 	"net/http"
+	"os"
 
 	"github.com/porter-dev/porter/internal/models"
 	"github.com/porter-dev/porter/internal/repository/gorm"
@@ -19,7 +21,20 @@ import (
 	ints "github.com/porter-dev/porter/internal/models/integrations"
 )
 
+// Version will be linked by an ldflag during build
+var Version string = "dev"
+
 func main() {
+	var versionFlag bool
+	flag.BoolVar(&versionFlag, "version", false, "print version and exit")
+	flag.Parse()
+
+	// Exit safely when version is used
+	if versionFlag {
+		fmt.Println(Version)
+		os.Exit(0)
+	}
+
 	appConf := config.FromEnv()
 
 	logger := lr.NewConsole(appConf.Debug)

+ 3 - 0
go.sum

@@ -188,6 +188,7 @@ github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH
 github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
 github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
 github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
+github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04=
 github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
 github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
 github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc=
@@ -195,9 +196,11 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
 github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
 github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
 github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c=
 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
 github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
 github.com/coreos/rkt v1.30.0 h1:Kkt6sYeEGKxA3Y7SCrY+nHoXkWed6Jr2BBY42GqMymM=
 github.com/coreos/rkt v1.30.0/go.mod h1:O634mlH6U7qk87poQifK6M2rsFNt+FyUTWNMnP1hF1U=

+ 13 - 0
scripts/build/osx.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# Accepts the version as an argument
+
+go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=$1'" -a -tags cli -o ./porter ./cli &
+go build -ldflags="-w -s -X 'main.Version=$1'" -a -o ./docker-credential-porter ./cmd/docker-credential-porter/ &
+go build -ldflags="-w -s -X 'main.Version=$1'" -a -o ./portersvr ./cmd/app/ &
+wait
+
+mkdir -p /release/darwin
+zip --junk-paths /release/darwin/UNSIGNED_porter_$1_Darwin_x86_64.zip ./porter
+zip --junk-paths /release/darwin/UNSIGNED_portersvr_$1_Darwin_x86_64.zip ./portersvr
+zip --junk-paths /release/darwin/UNSIGNED_docker-credential-porter_$1_Darwin_x86_64.zip ./docker-credential-porter

+ 13 - 0
scripts/build/win.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+#
+# Accepts the version as an argument
+
+go build -ldflags="-w -s -X 'github.com/porter-dev/porter/cli/cmd.Version=$1'" -a -tags cli -o ./porter.exe ./cli &
+go build -ldflags="-w -s -X 'main.Version=$1'" -a -o ./docker-credential-porter.exe ./cmd/docker-credential-porter/ &
+go build -ldflags="-w -s -X 'main.Version=$1'" -a -o ./portersvr.exe ./cmd/app/ &
+wait
+
+mkdir -p /release/windows
+zip --junk-paths /release/windows/porter_$1_Windows_x86_64.zip ./porter.exe
+zip --junk-paths /release/windows/portersvr_$1_Windows_x86_64.zip ./portersvr.exe
+zip --junk-paths /release/windows/docker-credential-porter_$1_Windows_x86_64.zip ./docker-credential-porter.exe