Skip to content

Commit

Permalink
Build kopia binary as part of kanister-tools (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitjain235 committed Nov 11, 2022
1 parent 551e268 commit 125a7a8
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 114 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,5 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: tar -xvf ./src.tar.gz
- run: make update-kopia-image GOBORING=true
- run: make release-snapshot
- run: ./build/push_images.sh
3 changes: 3 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ dockers:
dockerfile: 'docker/tools/Dockerfile'
build_flag_templates:
- "--build-arg=kan_tools_version={{ .Tag }}"
# Refers to https://github.com/kopia/kopia/commit/317cc36892707ab9bdc5f6e4dea567d1e638a070
- "--build-arg=kopiaBuildCommit=317cc36"
- "--build-arg=kopiaRepoOrg=kopia"
extra_files:
- 'LICENSE'
- ids:
Expand Down
7 changes: 0 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ DOCKER_CONFIG ?= "$(HOME)/.docker"
# Mention the vm-driver that should be used to install OpenShift
vm-driver ?= "kvm"

# Refers to https://github.com/kopia/kopia/commit/317cc36892707ab9bdc5f6e4dea567d1e638a070
KOPIA_COMMIT_ID ?= "317cc36"

KOPIA_REPO ?= "kopia"
# Default OCP version in which the OpenShift apps are going to run
ocp_version ?= "4.10"
###
Expand Down Expand Up @@ -265,9 +261,6 @@ gorelease:
release-snapshot:
@$(MAKE) run CMD='-c "GORELEASER_CURRENT_TAG=v9.99.9-dev goreleaser --debug release --rm-dist --snapshot"'

update-kopia-image:
@/bin/bash ./build/update_kopia_image.sh -c $(KOPIA_COMMIT_ID) -r $(KOPIA_REPO) -b $(GOBORING)

go-mod-download:
@$(MAKE) run CMD='-c "go mod download"'

Expand Down
57 changes: 0 additions & 57 deletions build/update_kopia_image.sh

This file was deleted.

46 changes: 0 additions & 46 deletions docker/kopia-build/Dockerfile

This file was deleted.

45 changes: 42 additions & 3 deletions docker/tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
# Build Kopia binary
FROM golang:1.19-bullseye AS builder

ARG kopia_build_commit=master
ARG kopia_repo_org=kopia
ENV CGO_ENABLED=1 GOEXPERIMENT=boringcrypto GO_EXTLINK_ENABLED=0
RUN apt-get install git

WORKDIR /

RUN git clone https://github.com/${kopia_repo_org}/kopia.git

ENV GITHUB_REPOSITORY=https://github.com/${kopia_repo_org}/kopia

WORKDIR /kopia

# Build kopia binary from specific commit
RUN git checkout ${kopia_build_commit}
RUN GO111MODULE=on GOOS=linux GOARCH=amd64 go build -o kopia \
-ldflags="-X github.com/kopia/kopia/repo.BuildVersion=$(git show --no-patch --format='%cs-%h') \
-X github.com/kopia/kopia/repo.BuildInfo=$(git show --no-patch --format='%cI-%H')-${kopia_build_commit} \
-X github.com/kopia/kopia/repo.BuildGitHubRepo=${kopia_repo_org}" .

RUN adduser kopia && addgroup kopia kopia
USER kopia:kopia

COPY --chown=kopia . /kopia

FROM debian:bullseye

WORKDIR /kopia

# Add CA certs
RUN apt-get update && apt-get -y install ca-certificates && \
rm -rf /var/cache/apk/* && \
adduser kopia && addgroup kopia kopia && \
chown kopia /kopia

USER kopia:kopia

# Build tools image
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-923
ARG kan_tools_version="test-version"
LABEL name="kanister-tools" \
Expand All @@ -9,9 +50,7 @@ LABEL name="kanister-tools" \
description="Kanister tools for application-specific data management"

COPY --from=restic/restic:0.11.0 /usr/bin/restic /usr/local/bin/restic
# ghcr.io/kanisterio/kopia:debian-317cc36-boring
COPY --from=ghcr.io/kanisterio/kopia@sha256:85eea9020ec81bc9cb56e46533e5195074680ebc4c91eefaec3cc97a9ffd5482 \
/kopia/kopia /usr/local/bin/kopia
COPY --from=builder /kopia/kopia /usr/local/bin/kopia
COPY LICENSE /licenses/LICENSE

ADD kando /usr/local/bin/
Expand Down

0 comments on commit 125a7a8

Please sign in to comment.