Skip to content

Commit fd515c2

Browse files
Refactor builds (#536)
* switch to matrix build strategy Co-authored-by: Carter Socha <[email protected]>
1 parent 340c506 commit fd515c2

File tree

5 files changed

+83
-22
lines changed

5 files changed

+83
-22
lines changed

.github/workflows/release.yml

Lines changed: 74 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Release"
1+
name: "Build and Publish"
22

33
on:
44
release:
@@ -16,36 +16,96 @@ jobs:
1616
DOCKERHUB_REPO: "otel/demo"
1717
GHCR_REPO: "ghcr.io/open-telemetry/demo"
1818

19+
strategy:
20+
matrix:
21+
file_tag:
22+
- file: ./src/adservice/Dockerfile
23+
tag_suffix: adservice
24+
context: ./
25+
- file: ./src/cartservice/src/Dockerfile
26+
tag_suffix: cartservice
27+
context: ./
28+
- file: ./src/checkoutservice/Dockerfile
29+
tag_suffix: checkoutservice
30+
context: ./
31+
- file: ./src/currencyservice/Dockerfile
32+
tag_suffix: currencyservice
33+
context: ./src/currencyservice
34+
- file: ./src/emailservice/Dockerfile
35+
tag_suffix: emailservice
36+
context: ./src/emailservice
37+
- file: ./src/frontend/Dockerfile
38+
tag_suffix: frontend
39+
context: ./
40+
- file: ./src/frontendproxy/Dockerfile
41+
tag_suffix: frontendproxy
42+
context: ./
43+
- file: ./src/paymentservice/Dockerfile
44+
tag_suffix: paymentservice
45+
context: ./
46+
- file: ./src/productcatalogservice/Dockerfile
47+
tag_suffix: productcatalogservice
48+
context: ./
49+
- file: ./src/quoteservice/Dockerfile
50+
tag_suffix: quoteservice
51+
context: ./
52+
- file: ./src/shippingservice/Dockerfile
53+
tag_suffix: shippingservice
54+
context: ./
55+
- file: ./src/featureflagservice/Dockerfile
56+
tag_suffix: featureflagservice
57+
context: ./src/featureflagservice
58+
- file: ./src/loadgenerator/Dockerfile
59+
tag_suffix: loadgenerator
60+
context: ./
61+
- file: ./src/recommendationservice/Dockerfile
62+
tag_suffix: recommendationservice
63+
context: ./
64+
- file: ./src/frontend/Dockerfile.cypress
65+
tag_suffix: frontend-tests
66+
context: ./
67+
- file: ./test/Dockerfile
68+
tag_suffix: integrationTests
69+
context: ./
1970
steps:
2071
- uses: actions/checkout@v3
2172
with:
2273
fetch-depth: 0
2374

24-
# limit docker push image concurrency to 1
25-
# to avoid github package return 429 ratelimit error
26-
- name: Set docker upload concurrent
27-
run: |
28-
echo $'{"max-concurrent-uploads": 1}' | sudo dd status=none of=/etc/docker/daemon.json
29-
sudo service docker restart
30-
3175
- name: Log in to the Container registry
3276
uses: docker/login-action@v2
3377
with:
3478
registry: ghcr.io
3579
username: ${{ github.repository_owner }}
3680
password: ${{ secrets.GITHUB_TOKEN }}
81+
if: github.event_name != 'pull_request'
3782

3883
- name: Log in to Docker Hub
3984
uses: docker/login-action@v2
4085
with:
4186
username: ${{ secrets.DOCKER_USERNAME }}
4287
password: ${{ secrets.DOCKER_PASSWORD }}
88+
if: github.event_name != 'pull_request'
4389

44-
- name: prepare build env
45-
run: make build-env-file
90+
- name: Set up QEMU
91+
uses: docker/setup-qemu-action@v2
4692

47-
- name: build and push ghcr docker image
48-
run: make build-and-push-ghcr
93+
- name: Set up Docker Buildx
94+
uses: docker/setup-buildx-action@v2
95+
with:
96+
config-inline: |
97+
[worker.oci]
98+
max-parallelism = 2
4999
50-
- name: build and push dockerhub image
51-
run: make build-and-push-dockerhub
100+
- name: Matrix Build and push demo images
101+
uses: docker/[email protected]
102+
with:
103+
context: ${{ matrix.file_tag.context }}
104+
file: ${{ matrix.file_tag.file }}
105+
platforms: linux/amd64
106+
push: ${{ github.event_name != 'pull_request' }}
107+
tags: |
108+
${{ env.DOCKERHUB_REPO }}:${{ env.RELEASE_VERSION || 'pr' }}-${{matrix.file_tag.tag_suffix }}
109+
${{ env.GHCR_REPO }}:${{ env.RELEASE_VERSION || 'pr' }}-${{ matrix.file_tag.tag_suffix }}
110+
cache-from: type=gha
111+
cache-to: type=gha

src/currencyservice/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ RUN apt-get install -qq -y --ignore-missing \
1515
cmake
1616

1717
# The following arguments would be passed from docker-compose.yml
18-
ARG GRPC_VERSION
19-
ARG OPENTELEMETRY_VERSION
18+
ARG GRPC_VERSION=1.46.0
19+
ARG OPENTELEMETRY_VERSION=1.5.0
2020

2121
# Install GRPC
2222
RUN git clone --shallow-submodules --depth 1 --recurse-submodules -b v${GRPC_VERSION} \

src/featureflagservice/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# - Ex: hexpm/elixir:1.13.3-erlang-25.0-debian-bullseye-20210902-slim
1414
#
1515
ARG ELIXIR_VERSION=1.13.3
16-
ARG OTP_VERSION=25.0
16+
ARG OTP_VERSION=23.0
1717
ARG DEBIAN_VERSION=bullseye-20210902-slim
1818

1919
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
@@ -29,8 +29,8 @@ RUN apt-get update -y && apt-get install -y build-essential git \
2929
WORKDIR /app
3030

3131
# install hex + rebar
32-
RUN mix local.hex --force && \
33-
mix local.rebar --force
32+
RUN mix local.hex --force --verbose
33+
RUN mix local.rebar --force --verbose
3434

3535
# set build ENV
3636
ENV MIX_ENV="prod"

src/shippingservice/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ RUN apk add --no-cache ca-certificates git protobuf-dev protoc cmake clang clang
55
WORKDIR /app/
66

77
# build app
8-
COPY ./src/shippingservice/ /app/
9-
COPY ./pb/ /app/proto/
8+
COPY /src/shippingservice/ /app/
9+
COPY /pb/ /app/proto/
10+
1011
RUN cargo build -r --features="dockerproto"
1112

1213
FROM alpine as release

src/shippingservice/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() -> Result<(), Box<dyn std::error::Error>> {
22
#[cfg(feature = "dockerproto")]
3-
tonic_build::compile_protos("proto/demo.proto")?;
3+
tonic_build::compile_protos("/app/proto/demo.proto")?;
44
#[cfg(not(feature = "dockerproto"))]
55
tonic_build::compile_protos("../../pb/demo.proto")?;
66
Ok(())

0 commit comments

Comments
 (0)