1
0
mirror of https://github.com/cs3org/reva.git synced 2025-04-18 13:44:12 +03:00

Improve Docker build speed and Docker Compose test speed (#3712)

* Optimize docker image build

* Cache non local images

* Reduce files to copy to docker build stage 1

* Use docker compose from Makefile

* Fix return code

* Fix ceph build and improve docker-compose performance

* improve revad docker image build speed

* Improve revad-eos docker image build speed
This commit is contained in:
Vasco Guita 2023-03-09 08:59:08 +01:00 committed by GitHub
parent 6bf090b308
commit 056bb770fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 79 additions and 86 deletions

View File

@ -1,7 +1,9 @@
.github
.git
changelog
docker
docs
grpc-tests
tests
toolchain
tools
*.md

View File

@ -5,6 +5,9 @@ on:
test:
required: true
type: string
image:
required: true
type: string
submodules:
type: boolean
parts:
@ -23,15 +26,15 @@ jobs:
- name: Download image
uses: ishworkh/docker-image-artifact-download@v1
with:
image: revad:test
image: ${{ inputs.image }}
- name: Test
uses: isbang/compose-action@v1.4.1
with:
compose-file: ./tests/docker/docker-compose.yml
up-flags: --force-recreate --always-recreate-deps --build --abort-on-container-exit -V --remove-orphans --exit-code-from ${{ inputs.test }}
down-flags: --rmi all -v --remove-orphans
services: ${{ inputs.test }}
run: make ${{ inputs.test }} -o docker-revad
env:
REVAD_IMAGE: revad:test
REVAD_IMAGE: ${{ inputs.image }}
PARTS: ${{ inputs.parts }}
PART: ${{ inputs.part }}
- name: Clean
if: always()
run: make docker-clean
env:
REVAD_IMAGE: ${{ inputs.image }}

View File

@ -13,10 +13,15 @@ on:
type: boolean
platforms:
type: string
outputs:
image:
value: ${{ jobs.docker.outputs.image }}
jobs:
docker:
runs-on: self-hosted
outputs:
image: ${{ steps.build.outputs.imageid }}
steps:
- name: Checkout
uses: actions/checkout@v3.1.0
@ -33,6 +38,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build ${{ inputs.push && 'and push' || '' }} ${{ inputs.tags }} Docker image
uses: docker/build-push-action@v3
id: build
with:
context: .
file: ${{ inputs.file }}
@ -40,9 +46,9 @@ jobs:
load: ${{ inputs.load }}
push: ${{ inputs.push }}
platforms: ${{ inputs.platforms }}
- name: Upload ${{ inputs.tags }} Docker image to artifacts
- name: Upload ${{ steps.build.outputs.imageid }} Docker image to artifacts
uses: ishworkh/docker-image-artifact-upload@v1
if: inputs.load
with:
image: ${{ inputs.tags }}
image: ${{ steps.build.outputs.imageid }}
retention_days: '1'

View File

@ -56,7 +56,6 @@ jobs:
uses: ./.github/workflows/docker.yml
with:
file: docker/Dockerfile.revad
tags: revad:test
load: true
litmus:
needs: docker-revad
@ -67,12 +66,14 @@ jobs:
uses: ./.github/workflows/compose.yml
with:
test: ${{ matrix.test }}
image: ${{ needs.docker-revad.outputs.image }}
acceptance-1:
needs: docker-revad
uses: ./.github/workflows/compose.yml
with:
test: acceptance-1
image: ${{ needs.docker-revad.outputs.image }}
submodules: true
needs: docker-revad
acceptance-2:
needs: docker-revad
strategy:
@ -82,6 +83,7 @@ jobs:
uses: ./.github/workflows/compose.yml
with:
test: acceptance-2
image: ${{ needs.docker-revad.outputs.image }}
submodules: true
parts: 6
part: ${{ matrix.part }}
@ -94,6 +96,7 @@ jobs:
uses: ./.github/workflows/compose.yml
with:
test: acceptance-3
image: ${{ needs.docker-revad.outputs.image }}
submodules: true
parts: 12
part: ${{ matrix.part }}

View File

@ -48,19 +48,19 @@ reva:
.PHONY: docker-reva
docker-reva:
docker build -f docker/Dockerfile.reva -t reva .
docker build -f docker/Dockerfile.reva -t reva --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
.PHONY: docker-revad
docker-revad:
docker build -f docker/Dockerfile.revad -t revad .
docker build -f docker/Dockerfile.revad -t revad --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
.PHONY: docker-revad-ceph
docker-revad-ceph:
docker build -f docker/Dockerfile.revad-ceph -t revad-ceph .
docker build -f docker/Dockerfile.revad-ceph -t revad-ceph --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
.PHONY: docker-revad-eos
docker-revad-eos:
docker build -f docker/Dockerfile.revad-eos -t revad-eos .
docker build -f docker/Dockerfile.revad-eos -t revad-eos --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .
################################################################################
# Test
@ -73,8 +73,7 @@ export PART ?= 1
.PHONY: $(TEST)
$(TEST): docker-revad
docker-compose -f ./tests/docker/docker-compose.yml up --force-recreate --always-recreate-deps --build --abort-on-container-exit -V --remove-orphans --exit-code-from $@ $@; \
docker-compose -f ./tests/docker/docker-compose.yml down --rmi all -v --remove-orphans
docker compose -f ./tests/docker/docker-compose.yml up --force-recreate --always-recreate-deps --build --abort-on-container-exit -V --remove-orphans --exit-code-from $@ $@
.PHONY: test-go
test-go:
@ -123,6 +122,11 @@ dist: gen-doc
toolchain-clean:
rm -rf $(TOOLCHAIN)
.PHONY: docker-clean
docker-clean:
docker compose -f ./tests/docker/docker-compose.yml down --rmi local -v --remove-orphans
docker rmi $(REVAD_IMAGE)
.PHONY: clean
clean: toolchain-clean
clean: toolchain-clean docker-clean
rm -rf dist

View File

@ -0,0 +1,3 @@
Enhancement: Improve Docker build speed and Docker Compose test speed
https://github.com/cs3org/reva/pull/3712

View File

@ -31,6 +31,10 @@ ENV GOPATH /go
WORKDIR /go/src/github/cs3org/reva
COPY . .
ARG GIT_COMMIT
ARG VERSION
ENV GIT_COMMIT=$GIT_COMMIT
ENV VERSION=$VERSION
RUN make reva && cp /go/src/github/cs3org/reva/cmd/reva/reva /go/bin/reva
FROM scratch

View File

@ -18,25 +18,19 @@
FROM golang:alpine3.16 as builder
RUN apk --no-cache add \
ca-certificates \
make
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
WORKDIR /go/src/github/cs3org/reva
WORKDIR /home/reva
COPY . .
RUN make revad && \
cp /go/src/github/cs3org/reva/cmd/revad/revad /go/bin/revad
RUN mkdir -p /etc/revad/ && touch /etc/revad/revad.toml
ARG GIT_COMMIT
ARG VERSION
ENV GIT_COMMIT=$GIT_COMMIT
ENV VERSION=$VERSION
RUN go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.version=$VERSION -X main.goVersion=`go version | awk '{print $3}'` -X main.buildDate=`date +%FT%T%z`" -o ./cmd/revad/revad ./cmd/revad
FROM alpine:3.16
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/bin/revad /usr/bin/revad
COPY --from=builder /etc/revad /etc/revad
COPY --from=builder /home/reva/cmd/revad/revad /usr/bin/revad
RUN mkdir -p /etc/revad/ && touch /etc/revad/revad.toml
ENTRYPOINT [ "/usr/bin/revad" ]
CMD [ "-c", "/etc/revad/revad.toml", "-p", "/var/run/revad.pid" ]

View File

@ -38,6 +38,11 @@ ENV GOPATH /go
WORKDIR /go/src/github/cs3org/reva
COPY . .
ARG GIT_COMMIT
ARG VERSION
ENV GIT_COMMIT=$GIT_COMMIT
ENV VERSION=$VERSION
RUN mkdir -p /go/bin && \
make revad-ceph && \
cp /go/src/github/cs3org/reva/cmd/revad/revad /usr/bin/revad

View File

@ -18,25 +18,20 @@
FROM golang:alpine3.16 as builder
RUN apk --no-cache add \
ca-certificates \
make
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
WORKDIR /go/src/github/cs3org/reva
WORKDIR /home/reva
COPY . .
RUN make revad && \
cp /go/src/github/cs3org/reva/cmd/revad/revad /go/bin/revad
RUN mkdir -p /etc/revad/ && touch /etc/revad/revad.toml
ARG GIT_COMMIT
ARG VERSION
ENV GIT_COMMIT=$GIT_COMMIT
ENV VERSION=$VERSION
RUN go build -ldflags "-X main.gitCommit=$GIT_COMMIT -X main.version=$VERSION -X main.goVersion=`go version | awk '{print $3}'` -X main.buildDate=`date +%FT%T%z`" -o ./cmd/revad/revad ./cmd/revad
FROM gitlab-registry.cern.ch/dss/eos/eos-all:4.8.91
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /go/bin/revad /usr/bin/revad
COPY --from=builder /etc/revad /etc/revad
COPY --from=builder /home/reva/cmd/revad/revad /usr/bin/revad
RUN mkdir -p /etc/revad/ && touch /etc/revad/revad.toml
ENTRYPOINT [ "/usr/bin/revad" ]
CMD [ "-c", "/etc/revad/revad.toml", "-p", "/var/run/revad.pid" ]

View File

@ -6,7 +6,7 @@ services:
- ../revad:/etc/revad
working_dir: /etc/revad/
healthcheck:
test: sleep 10
test: sleep 5
litmus:
image: registry.cern.ch/docker.io/owncloud/litmus:latest
environment:
@ -28,8 +28,6 @@ services:
gateway:
extends: revad
command: -c /etc/revad/gateway.toml
healthcheck:
test: sleep 5
volumes:
- shared-volume:/var/tmp
frontend:
@ -37,39 +35,29 @@ services:
command: -c /etc/revad/frontend.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
storage-home-ocis:
extends: revad
hostname: storage-home
command: -c /etc/revad/storage-home-ocis.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
users:
extends: revad
command: -c /etc/revad/users.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
shares:
extends: revad
command: -c /etc/revad/shares.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
litmus-1:
extends: litmus
environment:
LITMUS_URL: http://frontend:20080/remote.php/webdav
depends_on:
gateway:
condition: service_healthy
frontend:
condition: service_healthy
storage-home-ocis:
@ -83,6 +71,8 @@ services:
environment:
LITMUS_URL: http://frontend:20080/remote.php/dav/files/4c510ada-c86b-4815-8820-42cdf82c3d51
depends_on:
gateway:
condition: service_healthy
frontend:
condition: service_healthy
storage-home-ocis:
@ -94,18 +84,12 @@ services:
permissions-ocis-ci:
extends: revad
command: -c /etc/revad/permissions-ocis-ci.toml
depends_on:
gateway:
condition: service_healthy
storage-users-ocis:
extends: revad
hostname: storage-users
command: -c /etc/revad/storage-users-ocis.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
litmus-3:
extends: litmus
entrypoint: /bin/sh
@ -118,6 +102,8 @@ services:
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
frontend:
condition: service_healthy
storage-home-ocis:
@ -136,25 +122,16 @@ services:
command: -c /etc/revad/frontend-global.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
storage-local-1:
extends: revad
command: -c /etc/revad/storage-local-1.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
storage-local-2:
extends: revad
command: -c /etc/revad/storage-local-2.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
acceptance-1:
extends: acceptance
environment:
@ -170,6 +147,8 @@ services:
- shared-volume:/var/tmp
working_dir: /mnt/acceptance
depends_on:
gateway:
condition: service_healthy
frontend-global:
condition: service_healthy
storage-home-ocis:
@ -200,9 +179,6 @@ services:
command: -c /etc/revad/storage-publiclink.toml
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
ldap-users:
extends: revad
hostname: users
@ -210,8 +186,6 @@ services:
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
ldap:
condition: service_healthy
acceptance-2:
@ -233,6 +207,8 @@ services:
- shared-volume:/var/tmp
working_dir: /mnt/ocis
depends_on:
gateway:
condition: service_healthy
frontend:
condition: service_healthy
storage-home-ocis:
@ -270,8 +246,6 @@ services:
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
ceph:
condition: service_healthy
storage-users-s3ng:
@ -281,8 +255,6 @@ services:
volumes:
- shared-volume:/var/tmp
depends_on:
gateway:
condition: service_healthy
ceph:
condition: service_healthy
acceptance-3:
@ -304,6 +276,8 @@ services:
- shared-volume:/var/tmp
working_dir: /mnt/ocis
depends_on:
gateway:
condition: service_healthy
frontend:
condition: service_healthy
shares: