This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f558bfaf1 CDN in a Box: aarch64 support (#7260)
3f558bfaf1 is described below

commit 3f558bfaf13199ee97a32945441af6a6a8487719
Author: Zach Hoffman <[email protected]>
AuthorDate: Tue Jan 3 12:28:13 2023 -0700

    CDN in a Box: aarch64 support (#7260)
    
    * Get current architecture for postgres repo URL
    
    * Get golang from multiarch image instead of downloading it
    
    * Make CDN in a Box readme architecture-agnostic
---
 infrastructure/cdn-in-a-box/.env                   |  1 +
 infrastructure/cdn-in-a-box/README.md              | 13 +++++--------
 infrastructure/cdn-in-a-box/docker-compose.yml     |  2 ++
 infrastructure/cdn-in-a-box/enroller/Dockerfile    | 12 +++++-------
 infrastructure/cdn-in-a-box/traffic_ops/Dockerfile |  2 +-
 .../traffic_ops_integration_test/Dockerfile        | 22 ++++++----------------
 .../traffic_router_load_test/Dockerfile            | 21 ++++++---------------
 7 files changed, 26 insertions(+), 47 deletions(-)

diff --git a/infrastructure/cdn-in-a-box/.env b/infrastructure/cdn-in-a-box/.env
new file mode 120000
index 0000000000..c7360fb82d
--- /dev/null
+++ b/infrastructure/cdn-in-a-box/.env
@@ -0,0 +1 @@
+../../.env
\ No newline at end of file
diff --git a/infrastructure/cdn-in-a-box/README.md 
b/infrastructure/cdn-in-a-box/README.md
index b115992db3..c6f29b0dfb 100644
--- a/infrastructure/cdn-in-a-box/README.md
+++ b/infrastructure/cdn-in-a-box/README.md
@@ -183,18 +183,15 @@ Try disabling SELinux or setting it to 'permissive'. 
SELinux hates letting conta
 
 Bring all components down, remove the `traffic_ops/ca` directory, and delete 
the volumes with `docker volume prune`. This will force the regeneration of the 
certificates.
 
-## Notes for Apple M1 Pro Configuration
+## Notes for macOS
 
-### Code edits in the cdn-in-a-box directory
+CDN in a Box should work, without modification, on any architecture that can 
run Docker. If it does not, that is a bug, please open a new issue for it.
 
-Re/installed docker from the command line to use `--user=[your username]` 
flag, and update the dockerfiles in the code for both enroller and traffic_ops 
in the cdn-in-a-box folders with the correct architecture for the M1. Link to 
install info for docker for [Install from command line] 
(https://docs.docker.com/desktop/install/mac-install/)  and use Install from 
command line located in the "Mac with Apple Silicon" tab. 
+Re/installed docker from the command line to use `--user=[your username]` 
flag. Link to install info for docker for [Install from command line] 
(https://docs.docker.com/desktop/install/mac-install/)  and use Install from 
command line located in the "Mac with Apple Silicon" tab.
 
-- At the postgresql install, update the cdn-in-a-box/traffic_ops Dockerfile to 
`-aarch64/pgdg-redhat-repo-latest.noarch.rpm` right after 
`EL-${RHEL_VERSION%%.*}`.
-- At the first `FROM` of the cdn-in-a-box/enroller Dockerfile, append 
`--platform=linux/amd64`.
- 
 Build and run of it:
 In the trafficcontrol/infrastructure/cdn-in-a-box directory run the following:
- 
+
 - `make build-builders` ~~> this will create all the rpms and copy each rpms 
into its own folder in the cdn-in-a-box project. This will also create the dist 
folder under trafficcontrol folder structure even if you deleted yours.
 
 - `docker-compose up` ~~> this will create docker images, and if rebuild is 
needed, run `docker-compose up --build`.
@@ -211,4 +208,4 @@ The limitation of this approach is that Docker Desktop can 
only be run by one us
 
 The above is a direct quote found in [Installing from the commandline] 
(https://docs.docker.com/desktop/mac/permission-requirements/)
 
-Note: The Install from command line was the only install that resolved my 
issue of being unable to build the docker images and run the containers in 
localhost. Homebrew and the usual automatic install when double-clicking in the 
Docker.dmg did not work.
\ No newline at end of file
+Note: The Install from command line was the only install that resolved my 
issue of being unable to build the docker images and run the containers in 
localhost. Homebrew and the usual automatic install when double-clicking in the 
Docker.dmg did not work.
diff --git a/infrastructure/cdn-in-a-box/docker-compose.yml 
b/infrastructure/cdn-in-a-box/docker-compose.yml
index 1c70110a6b..d7fc31ac8b 100644
--- a/infrastructure/cdn-in-a-box/docker-compose.yml
+++ b/infrastructure/cdn-in-a-box/docker-compose.yml
@@ -259,6 +259,8 @@ services:
     build:
       context: ../..
       dockerfile: infrastructure/cdn-in-a-box/enroller/Dockerfile
+      args:
+          - GO_VERSION=${GO_VERSION}
     domainname: infra.ciab.test
     depends_on:
       - dns
diff --git a/infrastructure/cdn-in-a-box/enroller/Dockerfile 
b/infrastructure/cdn-in-a-box/enroller/Dockerfile
index 5a1d8bcecb..909a1fb6b7 100644
--- a/infrastructure/cdn-in-a-box/enroller/Dockerfile
+++ b/infrastructure/cdn-in-a-box/enroller/Dockerfile
@@ -15,6 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
+ARG GO_VERSION
+FROM golang:${GO_VERSION} AS get-go
 FROM debian:bullseye AS enroller-dependencies
 
 RUN apt-get update && \
@@ -24,13 +26,9 @@ RUN apt-get update && \
         wget && \
     apt-get clean
 
-COPY GO_VERSION /
-RUN go_version=$(cat /GO_VERSION) && \
-    wget -O go.tar.gz 
https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz && \
-    tar -C /usr/local -xvzf go.tar.gz && \
-    ln -s /usr/local/go/bin/go /usr/bin/go && \
-    rm go.tar.gz
-ENV GOPATH=/go \
+COPY --from=get-go /usr/local/go /usr/local/go
+ENV PATH=/usr/local/go/bin:${PATH} \
+    GOPATH=/go \
     CGO_ENABLED=0
 
 FROM enroller-dependencies AS enroller-builder
diff --git a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile 
b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
index 5c22f034ae..a53ed2493d 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops/Dockerfile
@@ -43,7 +43,7 @@ RUN set -o nounset -o errexit && \
                use_repo='--repo=pgdg13'; \
                enable_repo='--enablerepo=powertools'; \
        fi; \
-       dnf -y install 
"https://download.postgresql.org/pub/repos/yum/reporpms/EL-${RHEL_VERSION%%.*}-x86_64/pgdg-redhat-repo-latest.noarch.rpm";;
 \
+       dnf -y install 
"https://download.postgresql.org/pub/repos/yum/reporpms/EL-${RHEL_VERSION%%.*}-$(rpm
 --eval %_arch)/pgdg-redhat-repo-latest.noarch.rpm"; \
        dnf -y install epel-release libicu; \
        dnf -y $use_repo -- install postgresql13; \
        dnf -y $enable_repo install \
diff --git 
a/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile 
b/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile
index da17faa844..fe380b390f 100644
--- a/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_ops_integration_test/Dockerfile
@@ -15,23 +15,14 @@
 # specific language governing permissions and limitations
 # under the License.
 
+ARG GO_VERSION
+FROM golang:${GO_VERSION} AS get-go
 FROM alpine:3.13 AS integration-builder
 
-COPY GO_VERSION /
-RUN set -o errexit; \
-    go_version=$(cat /GO_VERSION); \
-    wget -O go.tar.gz 
https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz; \
-    tar -C /usr/local -xvzf go.tar.gz; \
-    ln -s /usr/local/go/bin/go /usr/bin/go; \
-    rm go.tar.gz; \
-    architecture=$(uname -m); \
-    mkdir lib64; \
-    # Use musl libc where the go binary expects glibc
-    # Less-generalized: ln -s /lib/ld-musl-x86_64.so.1 
/lib64/ld-linux-x86-64.so.2
-    ln -s /lib/ld-musl-${architecture}.so.[0-9] 
/lib64/ld-linux-${architecture//_/-}.so.2; \
-    # Test the go binary
-    go version
-ENV GOPATH=/go
+COPY --from=get-go /usr/local/go /usr/local/go
+ENV PATH=/usr/local/go/bin:${PATH} \
+    GOPATH=/go \
+    CGO_ENABLED=0
 ENV PATH="${PATH}:${GOPATH}/bin"
 
 RUN apk add --no-cache --update git gcc
@@ -54,7 +45,6 @@ COPY ./go.mod ./go.sum 
/go/src/github.com/apache/trafficcontrol/
 WORKDIR /go/src/github.com/apache/trafficcontrol/traffic_ops/testing/api
 RUN go mod vendor -v
 
-ENV CGO_ENABLED=0
 RUN set -o errexit -o xtrace;\
     for api_version in v3 v4; do\
         go test -c ./$api_version -ldflags="-w -s" -o 
traffic_ops_${api_version}_integration_test;\
diff --git a/infrastructure/cdn-in-a-box/traffic_router_load_test/Dockerfile 
b/infrastructure/cdn-in-a-box/traffic_router_load_test/Dockerfile
index e6e418cbf4..67f4ba6d23 100644
--- a/infrastructure/cdn-in-a-box/traffic_router_load_test/Dockerfile
+++ b/infrastructure/cdn-in-a-box/traffic_router_load_test/Dockerfile
@@ -15,23 +15,14 @@
 # specific language governing permissions and limitations
 # under the License.
 
+ARG GO_VERSION
+FROM golang:${GO_VERSION} AS get-go
 FROM alpine:3.14 AS load-test-builder
 
-COPY GO_VERSION /
-RUN set -o errexit; \
-    go_version=$(cat /GO_VERSION); \
-    wget -O go.tar.gz 
https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz; \
-    tar -C /usr/local -xvzf go.tar.gz; \
-    ln -s /usr/local/go/bin/go /usr/bin/go; \
-    rm go.tar.gz; \
-    architecture=$(uname -m); \
-    mkdir lib64; \
-    # Use musl libc where the go binary expects glibc
-    # Less-generalized: ln -s /lib/ld-musl-x86_64.so.1 
/lib64/ld-linux-x86-64.so.2
-    ln -s /lib/ld-musl-${architecture}.so.[0-9] 
/lib64/ld-linux-${architecture//_/-}.so.2; \
-    # Test the go binary
-    go version
-ENV GOPATH=/go CGO_ENABLED=0
+COPY --from=get-go /usr/local/go /usr/local/go
+ENV PATH=/usr/local/go/bin:${PATH} \
+    GOPATH=/go \
+    CGO_ENABLED=0
 ENV PATH="${PATH}:${GOPATH}/bin"
 ARG TC_DIR=${GOPATH}/src/github.com/apache/trafficcontrol
 

Reply via email to