Skip to content

Commit 53ad22a

Browse files
committed
Trying to pass the Linux as Docker build args.
1 parent c7266d0 commit 53ad22a

File tree

8 files changed

+76
-305
lines changed

8 files changed

+76
-305
lines changed

.github/workflows/reusable-docker.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,21 @@ jobs:
3636
env:
3737
DOCKER_OPTIONS: '--name ${{ INPUTS.IMAGE }} --platform ${{ INPUTS.PLATFORM }} --attach STDERR --attach STDOUT --quiet'
3838
DOCKER_IMAGE: ${{ INPUTS.REGISTRY }}/${{ INPUTS.USERNAME }}/${{ INPUTS.IMAGE }}:${{ INPUTS.TAG }}
39-
DOCKER_MOUNTS: '--volume ${{ GITHUB.WORKSPACE }}/.rpms:/home/github/.rpms'
39+
DOCKER_MOUNTS: '--volume ${{ RUNNER.TEMP }}/.rpms:/home/github/.rpms'
40+
# The images to build with are being defined right here.
41+
BUILD_ARGS_X86: '--build-arg LINUX_IMAGE=rockylinux/rockylinux:9.5'
42+
BUILD_ARGS_ARM: '--build-arg LINUX_IMAGE=arm64v8/rockylinux:9.3'
43+
outputs:
44+
BUILD_ARGS: string
4045
steps:
4146

47+
- name: Set up build args.
48+
id: build-args
49+
shell: bash
50+
run: |
51+
[ "${{ INPUTS.PLATFORM }}" = "linux/arm64" ] && echo BUILD_ARGS=${{ ENV.BUILD_ARGS_X86 }} >> $GITHUB_OUTPUT
52+
[ "${{ INPUTS.PLATFORM }}" = "linux/amd64" ] && echo BUILD_ARGS=${{ ENV.BUILD_ARGS_ARM }} >> $GITHUB_OUTPUT
53+
4254
# https://github.com/docker/login-action
4355
- name: Log in to the Container registry
4456
uses: 'docker/login-action@v3'
@@ -50,6 +62,7 @@ jobs:
5062

5163
# Need to check out once again, in order to utilize `hashFiles()`.
5264
- uses: 'actions/checkout@v4'
65+
5366
- name: Restore bazel cache
5467
if: ${{ contains(INPUTS.IMAGE, 'builder') }}
5568
id: bazel-cache-restore
@@ -68,10 +81,11 @@ jobs:
6881
shell: bash
6982
env:
7083
DOCKER_MOUNTS: '--volume ${{ RUNNER.TEMP }}/.cache:/home/runner/.cache --volume ${{ RUNNER.TEMP }}/.rpms:/home/runner/.rpms'
84+
BUILD_ARGS: ${{ steps.build-args.outputs.BUILD_ARGS }}
7185
run: |
7286
mkdir -p ${{ RUNNER.TEMP }}/.rpms
7387
mkdir -p ${{ RUNNER.TEMP }}/.cache
74-
docker run $DOCKER_OPTIONS $DOCKER_MOUNTS $DOCKER_IMAGE
88+
docker run $DOCKER_OPTIONS $DOCKER_MOUNTS $BUILD_ARGS $DOCKER_IMAGE
7589
7690
- name: List ${{ RUNNER.TEMP }}
7791
if: ${{ contains(INPUTS.IMAGE, 'builder') }}
@@ -108,9 +122,10 @@ jobs:
108122
shell: bash
109123
env:
110124
DOCKER_MOUNTS: '--volume ${{ RUNNER.TEMP }}/.rpms:/home/runner/.rpms'
125+
BUILD_ARGS: ${{ steps.build-args.outputs.BUILD_ARGS }}
111126
run: |
112127
mkdir -p ${{ RUNNER.TEMP }}/.rpms
113-
docker run $DOCKER_OPTIONS $DOCKER_MOUNTS $DOCKER_IMAGE
128+
docker run $DOCKER_OPTIONS $DOCKER_MOUNTS $BUILD_ARGS $DOCKER_IMAGE
114129
115130
# https://docs.docker.com/reference/cli/docker/container/run/
116131
- name: Build orchestration image
@@ -119,6 +134,7 @@ jobs:
119134
shell: bash
120135
env:
121136
DOCKER_MOUNTS: '--volume ${{ RUNNER.TEMP }}/.rpms:/home/runner/.rpms'
137+
BUILD_ARGS: ${{ steps.build-args.outputs.BUILD_ARGS }}
122138
run: |
123139
mkdir -p ${{ RUNNER.TEMP }}/.rpms
124-
docker run $DOCKER_OPTIONS $DOCKER_MOUNTS $DOCKER_IMAGE
140+
docker run $DOCKER_OPTIONS $DOCKER_MOUNTS $BUILD_ARGS $DOCKER_IMAGE

.github/workflows/rpm-builder.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ jobs:
100100
- image: rpm-builder-amd64
101101
runner: ubuntu-latest
102102
platform: linux/amd64
103-
dirname: x86_64
104103
- image: rpm-builder-arm64
105104
runner: ubuntu-24.04-arm
106105
platform: linux/arm64
107-
dirname: arm_64
108106

109107
# This must be a job, in order to pass `secrets`.
110108
preinstall-integration:

docker/rpm-builder-integration/x86_64/Dockerfile renamed to docker/rpm-builder-integration/Dockerfile

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,30 @@ WORKDIR "/root"
88
# GitHub Arguments
99
# TODO: To be changed to `google` upon merging to `main` branch.
1010
# This is merely being used in `clone.sh`, to switch the correct brach.
11-
ARG USER="syslogic"
12-
ARG REPO="android-cuttlefish"
11+
ARG GITHUB_USER="syslogic"
12+
ARG GITHUB_REPO="android-cuttlefish"
1313

1414
# PGP Arguments
1515
# TODO: PGP signature and passphrase are required to sign packages.
1616
ARG SIGNATURE=""
1717
ARG PASSPHRASE=""
1818

19-
# Adding the user provides the home directory.
20-
RUN [ "groupadd", "-g", "117", "docker" ]
21-
RUN [ "useradd", "-g", "117", "-u", "1001", "-s", "/bin/bash", "runner" ]
2219
# Note: The container scripts are checking for this file,
2320
# in order to prevent accidentlly running them on the host.
2421
RUN [ "touch", "/home/runner/.dockerenv" ]
2522

23+
# Adding the user provides the home directory.
24+
RUN [ "groupadd", "-g", "117", "docker" ]
25+
RUN [ "useradd", "-g", "117", "-u", "1001", "-s", "/bin/bash", "runner" ]
2626

27-
# Base Image
28-
FROM linux AS base_x86
29-
ENV REPO_USER="${USER}"
30-
ENV REPO_NAME="${REPO}"
27+
# Don't ask for the `sudo` password.
28+
RUN [ "echo", "%docker", "ALL=(ALL)", "NOPASSWD:", "ALL", ">", "/etc/sudoers.d/docker.conf" ]
3129

32-
# https://docs.docker.com/reference/dockerfile/#notes-about-specifying-volumes
33-
# The host directory is declared at container run-time, with `--volume`, eg.
34-
# --volume /home/username/android-cuttlefish/.rpms/:/home/github/.rpms
35-
WORKDIR "/home/runner"
36-
RUN [ "mkdir", "/home/runner/.rpms" ]
37-
VOLUME [ "/home/runner/.rpms" ]
30+
31+
# Base Image
32+
FROM linux AS base_image
33+
ENV REPO_USER="${GITHUB_USER}"
34+
ENV REPO_NAME="${GITHUB_REPO}"
3835

3936
# The EPEL repository installs `dnf-core-plugin` (`config-manager` and `builddeps`) and provides `ncurses-compat-libs`.
4037
# Configuring further package repositories: / https://wiki.rockylinux.org/rocky/repo/#extra-repositories
@@ -44,9 +41,15 @@ RUN [ "dnf", "config-manager", "--set-enabled", "crb" ]
4441
RUN [ "dnf", "-y", "upgrade" ]
4542
RUN [ "dnf", "clean", "all" ]
4643

44+
# https://docs.docker.com/reference/dockerfile/#notes-about-specifying-volumes
45+
# The host directory is declared at container run-time, with `--volume`, eg.
46+
# --volume /home/username/android-cuttlefish/.rpms/:/home/github/.rpms
47+
RUN [ "mkdir", "/home/runner/.rpms" ]
48+
VOLUME [ "/home/runner/.rpms" ]
49+
WORKDIR "/home/runner"
4750

4851
# Integration
49-
FROM base_x86 AS integration
52+
FROM base_image AS integration
5053
ENTRYPOINT [ "/bin/bash" ]
5154

5255
# Expose Operator Port (HTTP:1080, HTTPS:1443)
@@ -58,8 +61,6 @@ EXPOSE 15550-15560
5861
# Expose ADB
5962
EXPOSE 6520-6620
6063

61-
RUN [ "touch", "/home/runner/.dockerenv" ]
62-
RUN [ "echo", "%docker", "ALL=(ALL)", "NOPASSWD:", "ALL", ">", "/etc/sudoers.d/docker.conf" ]
6364
COPY [ "./docker/rpm-builder/scripts/install_rpm.sh", "/home/runner/install_rpm.sh" ]
6465
RUN [ "chmod", "+x", "/home/runner/install_rpm.sh" ]
6566

docker/rpm-builder-integration/arm_64/Dockerfile

Lines changed: 0 additions & 78 deletions
This file was deleted.

docker/rpm-builder-orchestration/x86_64/Dockerfile renamed to docker/rpm-builder-orchestration/Dockerfile

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,30 @@ WORKDIR "/root"
88
# GitHub Arguments
99
# TODO: To be changed to `google` upon merging to `main` branch.
1010
# This is merely being used in `clone.sh`, to switch the correct brach.
11-
ARG USER="syslogic"
12-
ARG REPO="android-cuttlefish"
11+
ARG GITHUB_USER="syslogic"
12+
ARG GITHUB_REPO="android-cuttlefish"
1313

1414
# PGP Arguments
1515
# TODO: PGP signature and passphrase are required to sign packages.
1616
ARG SIGNATURE=""
1717
ARG PASSPHRASE=""
1818

19-
# Adding the user provides the home directory.
20-
RUN [ "groupadd", "-g", "117", "docker" ]
21-
RUN [ "useradd", "-g", "117", "-u", "1001", "-s", "/bin/bash", "runner" ]
2219
# Note: The container scripts are checking for this file,
2320
# in order to prevent accidentlly running them on the host.
2421
RUN [ "touch", "/home/runner/.dockerenv" ]
2522

23+
# Adding the user provides the home directory.
24+
RUN [ "groupadd", "-g", "117", "docker" ]
25+
RUN [ "useradd", "-g", "117", "-u", "1001", "-s", "/bin/bash", "runner" ]
2626

27-
# Base Image
28-
FROM linux AS base
29-
ENV REPO_USER="${USER}"
30-
ENV REPO_NAME="${REPO}"
27+
# Don't ask for the `sudo` password.
28+
RUN [ "echo", "%docker", "ALL=(ALL)", "NOPASSWD:", "ALL", ">", "/etc/sudoers.d/docker.conf" ]
3129

32-
# https://docs.docker.com/reference/dockerfile/#notes-about-specifying-volumes
33-
# The host directory is declared at container run-time, with `--volume`, eg.
34-
# --volume /home/username/android-cuttlefish/.rpms/:/home/github/.rpms
35-
WORKDIR "/home/runner"
36-
RUN [ "mkdir", "/home/runner/.rpms" ]
37-
VOLUME [ "/home/runner/.rpms" ]
30+
31+
# Base Image
32+
FROM linux AS base_image
33+
ENV REPO_USER="${GITHUB_USER}"
34+
ENV REPO_NAME="${GITHUB_REPO}"
3835

3936
# The EPEL repository installs `dnf-core-plugin` (`config-manager` and `builddeps`) and provides `ncurses-compat-libs`.
4037
# Configuring further package repositories: / https://wiki.rockylinux.org/rocky/repo/#extra-repositories
@@ -44,9 +41,15 @@ RUN [ "dnf", "config-manager", "--set-enabled", "crb" ]
4441
RUN [ "dnf", "-y", "upgrade" ]
4542
RUN [ "dnf", "clean", "all" ]
4643

44+
# https://docs.docker.com/reference/dockerfile/#notes-about-specifying-volumes
45+
# The host directory is declared at container run-time, with `--volume`, eg.
46+
# --volume /home/username/android-cuttlefish/.rpms/:/home/github/.rpms
47+
RUN [ "mkdir", "/home/runner/.rpms" ]
48+
VOLUME [ "/home/runner/.rpms" ]
49+
WORKDIR "/home/runner"
4750

4851
# Host Orchestration
49-
FROM base AS orchestration
52+
FROM base_image AS orchestration
5053
ENTRYPOINT [ "/home/runner/services.sh" ]
5154

5255
# Expose Operator Port (HTTP:1080, HTTPS:1443)

docker/rpm-builder-orchestration/arm_64/Dockerfile

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)