Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate to skaffold ci #7

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .github/workflows/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ env:

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/[email protected]

- 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 }}
34 changes: 17 additions & 17 deletions .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ env:

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/[email protected]

- 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 }}
21 changes: 14 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
FROM golang:1.20-alpine as buildbase
FROM golang:1.22.2-alpine as buildbase

RUN apk add git build-base
ARG CI_JOB_TOKEN

RUN apk add git build-base ca-certificates
WORKDIR /go/src/github.com/rarimo/geo-forms-svc
COPY vendor .
COPY . .

RUN GOOS=linux go build -o /usr/local/bin/geo-forms-svc /go/src/github.com/rarimo/geo-forms-svc
RUN git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com".insteadOf https://gitlab.com
RUN git config --global url."https://${CI_JOB_TOKEN}@github.com/".insteadOf https://github.com/
RUN go env -w GOPRIVATE=github.com/*,gitlab.com/*

RUN go mod tidy && go mod vendor
RUN CGO_ENABLED=1 GO111MODULE=on GOOS=linux go build -o /usr/local/bin/geo-forms-svc /go/src/github.com/rarimo/geo-forms-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-forms-svc /usr/local/bin/geo-forms-svc
RUN apk add --no-cache ca-certificates
COPY --from=buildbase /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT ["geo-forms-svc"]
ENTRYPOINT ["geo-forms-svc"]
76 changes: 76 additions & 0 deletions skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
apiVersion: skaffold/v2beta28
kind: Config
build:
artifacts:
- image: geo-forms-svc # Change it on your own repo-name
docker:
buildArgs:
CI_JOB_TOKEN: "{{.CI_JOB_TOKEN}}"


# 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
4 changes: 0 additions & 4 deletions werf-giterminism.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions werf.yaml

This file was deleted.

Loading