diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 11c0936..d7c9b7c 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -3,29 +3,29 @@ on: jobs: converge: - name: Converge - runs-on: ubuntu-latest - steps: - + name: Skaffold Build To Github + runs-on: ubuntu-22.04 + steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Install werf - uses: werf/actions/install@v1.2 - - name: Log in to registry # This is where you will update the personal access token to GITHUB_TOKEN run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - name: Run echo - run: | - werf version - docker version - echo $GITHUB_REPOSITORY - echo $GITHUB_SHA - - name: Run Build - run: | - . $(werf ci-env github --as-file) - werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA + - name: Cache layers + uses: actions/cache@v3 + with: + path: "${{ github.workspace }}/.skaffold/cache" + key: skaffold-${{ hashFiles('**/cache') }} + restore-keys: | + skaffold- + + - name: Run Skaffold pipeline as command + uses: hiberbee/github-action-skaffold@latest + id: build + with: + command: build --tag ${{ github.sha }} + repository: ghcr.io/${{ github.repository_owner }} diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml index 9e0a856..0f37984 100644 --- a/.github/workflows/tag.yaml +++ b/.github/workflows/tag.yaml @@ -6,29 +6,29 @@ on: jobs: converge: - name: Converge - runs-on: ubuntu-latest - steps: - + name: Skaffold Build To Github + runs-on: ubuntu-22.04 + steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Install werf - uses: werf/actions/install@v1.2 - - name: Log in to registry # This is where you will update the personal access token to GITHUB_TOKEN run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - name: Run echo - run: | - werf version - docker version - echo $GITHUB_REPOSITORY - echo $GITHUB_REF_NAME - - name: Run Build - run: | - . $(werf ci-env github --as-file) - werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME + - name: Cache layers + uses: actions/cache@v3 + with: + path: "${{ github.workspace }}/.skaffold/cache" + key: skaffold-${{ hashFiles('**/cache') }} + restore-keys: | + skaffold- + + - name: Run Skaffold pipeline as command + uses: hiberbee/github-action-skaffold@latest + id: build + with: + command: build --tag ${{ github.ref_name }} + repository: ghcr.io/${{ github.repository_owner }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 37131bd..a577978 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,20 @@ -FROM golang:1.22-alpine as buildbase +FROM golang:1.19.7-alpine as buildbase -RUN apk add git build-base +RUN apk add git build-base ca-certificates WORKDIR /go/src/github.com/rarimo/geo-points-svc -COPY vendor . COPY . . +RUN go mod tidy && go mod vendor +RUN CGO_ENABLED=1 GO111MODULE=on GOOS=linux go build -o /usr/local/bin/geo-points-svc /go/src/github.com/rarimo/geo-points-svc -RUN GOOS=linux go build -o /usr/local/bin/geo-points-svc /go/src/github.com/rarimo/geo-points-svc - - -FROM alpine:3.9 +FROM scratch +COPY --from=alpine:3.9 /bin/sh /bin/sh +COPY --from=alpine:3.9 /usr /usr +COPY --from=alpine:3.9 /lib /lib COPY --from=buildbase /usr/local/bin/geo-points-svc /usr/local/bin/geo-points-svc -RUN apk add --no-cache ca-certificates +COPY --from=buildbase /go/src/github.com/rarimo/geo-points-svc/proof_keys/passport.json /proof_keys/passport.json +COPY --from=buildbase /go/src/github.com/rarimo/geo-points-svc/proof_keys/poll.json /proof_keys/poll.json +COPY --from=buildbase /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -ENTRYPOINT ["geo-points-svc"] +ENTRYPOINT ["geo-points-svc"] \ No newline at end of file diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 0000000..016dd69 --- /dev/null +++ b/skaffold.yaml @@ -0,0 +1,72 @@ +apiVersion: skaffold/v2beta28 +kind: Config +build: + artifacts: + - image: geo-points-svc # Change it on your own repo-name + +# Uncomment the following lines if you want to deploy your application +# profiles: +# - name: dev +# deploy: +# helm: +# releases: +# - name: backend # Change it on your own repo-name +# setValueTemplates: +# image.repository: "{{.IMAGE_REPO_backend}}" +# image.tag: "{{.IMAGE_TAG_backend}}" +# namespace: dev # Change it on your own namespace +# createNamespace: true +# chartPath: ./backend # Change it on your own path to helm chart +# valuesFiles: +# - ./backend/values.yaml # Change it on your own path to helm chart values.yaml file +# skipBuildDependencies: true +# flags: +# upgrade: +# - -i +# portForward: +# - resourceType: deployment +# resourceName: backend # Change it on your own name in Chart.yaml +# port: 8000 +# localPort: 8000 + +# - name: stage +# patches: +# - op: remove +# path: /build +# deploy: +# helm: +# releases: +# - name: backend # Change it on your own repo-name +# setValueTemplates: +# image.repository: "{{.SKAFFOLD_DEFAULT_REPO}}/{{.GITHUB_REPOSITORY}}" +# image.tag: "{{.GITHUB_SHA}}" +# namespace: stage # Change it on your own namespace +# createNamespace: true +# chartPath: ./backend # Change it on your own path to helm chart +# valuesFiles: +# - ./backend/values.yaml # Change it on your own path to helm chart values.yaml file +# skipBuildDependencies: true +# flags: +# upgrade: +# - -i + +# - name: prod +# patches: +# - op: remove +# path: /build +# deploy: +# helm: +# releases: +# - name: backend # Change it on your own repo-name +# setValueTemplates: +# image.repository: "{{.SKAFFOLD_DEFAULT_REPO}}/{{.GITHUB_REPOSITORY}}" +# image.tag: "{{.GITHUB_REF_NAME}}" +# namespace: prod # Change it on your own namespace +# createNamespace: true +# chartPath: ./backend # Change it on your own path to helm chart +# valuesFiles: +# - ./backend/values.yaml # Change it on your own path to helm chart values.yaml file +# skipBuildDependencies: true +# flags: +# upgrade: +# - -i \ No newline at end of file diff --git a/werf.yaml b/werf.yaml deleted file mode 100644 index dcf59f9..0000000 --- a/werf.yaml +++ /dev/null @@ -1,53 +0,0 @@ -configVersion: 1 -project: "geo-points-svc" ---- -image: builder -from: golang:1.22-alpine -docker: - WORKDIR: /go/src/github.com/rarimo/geo-points-svc -git: - - add: / - to: /go/src/github.com/rarimo/geo-points-svc - stageDependencies: - install: - - go.mod - - go.sum - setup: - - "**/*" -shell: - install: - - apk add git build-base - - export CGO_ENABLED=1 - - export GO111MODULE=on - - export GOOS=linux - - cd /go/src/github.com/rarimo/geo-points-svc - - go mod tidy - - go mod vendor - setup: - - export CGO_ENABLED=1 - - export GO111MODULE=on - - export GOOS=linux - - cd /go/src/github.com/rarimo/geo-points-svc - - go build -o /usr/local/bin/geo-points-svc /go/src/github.com/rarimo/geo-points-svc - ---- -image: service -from: alpine:3.9 -docker: - ENTRYPOINT: geo-points-svc -shell: - setup: - - apk add --no-cache ca-certificates -import: - - image: builder - add: /usr/local/bin/geo-points-svc - to: /usr/local/bin/geo-points-svc - after: setup - - image: builder - add: /go/src/github.com/rarimo/geo-points-svc/proof_keys/passport.json - to: /proof_keys/passport.json - after: setup - - image: builder - add: /go/src/github.com/rarimo/geo-points-svc/proof_keys/poll.json - to: /proof_keys/poll.json - after: setup