-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhances the image build process and refactors the workflows (#25)
* chore(CI/CD): Refactors the Docker image build process and CI/CD workflows * chore(SemVer): Release to 1.3.0 * chore(SemVer): Release to 1.3.0 --------- Co-authored-by: Bogdan Vidrean <bogdan.vidrean@olx.com>
- Loading branch information
1 parent
425de6d
commit 4b6f0d1
Showing
15 changed files
with
132 additions
and
201 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: pull-request-tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
container: rust:1.66.1-alpine3.17 | ||
services: | ||
backend: | ||
image: nginx:latest | ||
options: -v ${{ github.workspace }}/tests/resources/:/usr/share/nginx/html/ --name backend | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Restart nginx | ||
uses: docker://docker | ||
with: | ||
args: docker restart backend | ||
- uses: Swatinem/rust-cache@v1 | ||
- name: Install libvips | ||
run: apk add --update --no-cache | ||
--repository https://dl-cdn.alpinelinux.org/alpine/v3.17/community | ||
--repository https://dl-cdn.alpinelinux.org/alpine/v3.17/main | ||
curl | ||
musl-dev=1.2.3-r4 | ||
vips-dev=8.13.3-r1 | ||
vips-heif=8.13.3-r1 | ||
- name: Check if nginx is available for files hosting | ||
run: curl http://backend/exif --output /dev/null | ||
- name: Build Dali | ||
run: RUSTFLAGS="-C target-feature=-crt-static $(pkg-config vips --libs)" cargo build | ||
- name: Run Dali | ||
run: ./target/debug/dali >> /dev/null & | ||
- name: Check if Dali is running | ||
run: sleep 5 && nc -z localhost 8080 | ||
- name: Run tests | ||
run: RUSTFLAGS="-C target-feature=-crt-static $(pkg-config vips --libs)" HTTP_HOST=backend cargo test | ||
- name: Exit with the test result | ||
run: exit $? |
15 changes: 7 additions & 8 deletions
15
.github/workflows/base_image.yml → .github/workflows/release.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
# (c) Copyright 2019-2023 OLX | ||
name: build-base-images | ||
|
||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- Dockerfile.base | ||
- Dockerfile.vips | ||
- Makefile | ||
- .github/workflows/base_image.yml | ||
|
||
- Cargo.toml | ||
jobs: | ||
build_base_docker_image: | ||
publish_docker_image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Docker login | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Build and Publish to GPR | ||
run: make build-base-image | ||
run: make docker-publish |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
# (c) Copyright 2019-2023 OLX | ||
ARG BUILD_IMAGE=ghcr.io/olxgroup-oss/dali/base-rust-image | ||
ARG BASE_IMAGE=ghcr.io/olxgroup-oss/dali/base-dali | ||
|
||
FROM ${BUILD_IMAGE}:latest as build | ||
FROM rust:1.66.1-alpine3.17 as build | ||
|
||
WORKDIR /usr/src/dali | ||
RUN apk add --update --no-cache \ | ||
--repository https://dl-cdn.alpinelinux.org/alpine/v3.17/community \ | ||
--repository https://dl-cdn.alpinelinux.org/alpine/v3.17/main \ | ||
musl-dev=1.2.3-r4 \ | ||
vips-dev=8.13.3-r1 | ||
|
||
COPY . . | ||
|
||
# this flag ensures that proc macro can be compiled in musl targets | ||
RUN RUSTFLAGS="-C target-feature=-crt-static $(pkg-config vips --libs)" cargo install --path . | ||
RUN RUSTFLAGS="-C target-feature=-crt-static $(pkg-config vips --libs)" cargo build --release | ||
|
||
FROM alpine:3.17.2 | ||
|
||
FROM ${BASE_IMAGE}:latest | ||
RUN apk add --update --no-cache \ | ||
--repository https://dl-cdn.alpinelinux.org/alpine/v3.17/community \ | ||
--repository https://dl-cdn.alpinelinux.org/alpine/v3.17/main \ | ||
vips=8.13.3-r1 \ | ||
vips-heif=8.13.3-r1 \ | ||
openssl=3.0.8-r0 | ||
|
||
COPY --from=build /usr/local/cargo/bin/dali /usr/local/bin/dali | ||
COPY --from=build /usr/src/dali/target/release/dali /usr/local/bin/dali | ||
|
||
CMD dali | ||
CMD ["dali"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,27 @@ | ||
# (c) Copyright 2019-2023 OLX | ||
DOCKER_REGISTRY ?= ghcr.io | ||
DOCKER_ORG ?= olxgroup-oss | ||
BUILD_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_ORG)/dali/base-rust-image | ||
BASE_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_ORG)/dali/base-dali | ||
RUNTIME_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_ORG)/dali/dali | ||
DALI_IMAGE_NAME ?= $(DOCKER_REGISTRY)/$(DOCKER_ORG)/dali/dali | ||
BUILD_NUMBER ?= $(shell ./scripts/get-current-version.sh) | ||
|
||
PROJECT_NAME=dali | ||
|
||
REVISION ?= $(shell git rev-parse --short HEAD) | ||
ifeq ($(BUILD_NUMBER),) | ||
VERSION_TAG ?= $(REVISION) | ||
ifeq ($(REVISION),) | ||
VERSION_TAG ?= $(BUILD_NUMBER) | ||
else | ||
VERSION_TAG ?= $(REVISION)-$(BUILD_NUMBER) | ||
VERSION_TAG ?= $(REVISION)-preview | ||
endif | ||
|
||
SUDO := $(shell docker info >/dev/null 2>&1 || echo sudo) | ||
|
||
.PHONY: up test build-base-image build-image | ||
|
||
up: | ||
RUNTIME_IMAGE=$(RUNTIME_IMAGE) $(SUDO) docker-compose -p $(PROJECT_NAME) \ | ||
-f docker-compose.yaml \ | ||
up --remove-orphans --exit-code-from dali | ||
|
||
test: | ||
RUNTIME_IMAGE=$(RUNTIME_IMAGE) BUILD_IMAGE=$(BUILD_IMAGE) $(SUDO) docker-compose -p $(PROJECT_NAME) \ | ||
-f docker-compose.yaml -f docker-compose.tests.yaml \ | ||
up --no-recreate --remove-orphans --exit-code-from cargo | ||
./scripts/dali-tests-runner.sh | ||
|
||
run: | ||
cargo run | ||
|
||
build-base-image: | ||
$(SUDO) docker build -f Dockerfile.base -t "$(BUILD_IMAGE):$(VERSION_TAG)" . | ||
$(SUDO) docker build -f Dockerfile.vips -t "$(BASE_IMAGE):$(VERSION_TAG)" . | ||
$(SUDO) docker tag "$(BUILD_IMAGE):$(VERSION_TAG)" "$(BUILD_IMAGE):latest" | ||
$(SUDO) docker push "$(BUILD_IMAGE):$(VERSION_TAG)" | ||
$(SUDO) docker push "$(BUILD_IMAGE):latest" | ||
$(SUDO) docker tag "$(BASE_IMAGE):$(VERSION_TAG)" "$(BASE_IMAGE):latest" | ||
$(SUDO) docker push "$(BASE_IMAGE):$(VERSION_TAG)" | ||
$(SUDO) docker push "$(BASE_IMAGE):latest" | ||
docker-build: | ||
docker build -t ${DALI_IMAGE_NAME}:${VERSION_TAG} . | ||
|
||
build-image: | ||
$(SUDO) docker build --build-arg BASE_IMAGE=$(BASE_IMAGE) --build-arg BUILD_IMAGE=$(BUILD_IMAGE) -t "$(RUNTIME_IMAGE):$(VERSION_TAG)" . | ||
$(SUDO) docker tag "$(RUNTIME_IMAGE):$(VERSION_TAG)" "$(RUNTIME_IMAGE):latest" | ||
$(SUDO) docker push "$(RUNTIME_IMAGE):$(VERSION_TAG)" | ||
$(SUDO) docker push "$(RUNTIME_IMAGE):latest" | ||
docker-publish: docker-build | ||
docker push ${DALI_IMAGE_NAME}:${VERSION_TAG} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.