zrhoffman commented on a change in pull request #6532: URL: https://github.com/apache/trafficcontrol/pull/6532#discussion_r796432286
########## File path: dev/atc.dev.sh ########## @@ -0,0 +1,160 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +alias atc-start="docker-compose up -d --build"; +alias atc-build="docker-compose build"; +alias atc-stop="docker-compose down -v --remove-orphans"; Review comment: Doing `docker-compose kill` before `docker-compose down` makes it stop faster ########## File path: dev/traffic_router/Dockerfile ########## @@ -0,0 +1,28 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest AS trafficrouter-dev + +ENV TC=/root/go/src/github.com/apache/trafficcontrol +VOLUME /root/go/src/github.com/apache/trafficcontrol +ENV JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n" JAVA_HOME=/usr/lib/jvm/java-8-openjdk M2_HOME=/root/.m2/ +EXPOSE 3053:53/tcp 3053:53/udp 3080:80 3443:443 3333:3333 2222:3443 5005:5005 + +RUN apk add --no-cache openjdk8 inotify-tools maven && ln -s /usr/lib/jvm/java-1.8-openjdk/bin/jdb /bin/jdb + +ADD https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.54/bin/apache-tomcat-9.0.54.tar.gz /opt/tomcat.tgz Review comment: Getting a 404 ```dockerfile > [trafficrouter-dev] https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.54/bin/apache-tomcat-9.0.54.tar.gz: ------ failed to solve: rpc error: code = Unknown desc = failed to load cache key: invalid response status 404 ``` Since the expected Tomcat version is 9.0.43 according to https://github.com/apache/trafficcontrol/blob/85f1073154a8cf3754fb454984b1e50a7a4e636c/traffic_router/build/build_rpm.sh#L83-L84 and not the latest Tomcat 9.0.x version, this should use https://archive.apache.org/ instead of dlcdn.apache.org. ########## File path: dev/traffic_monitor/Dockerfile ########## @@ -0,0 +1,23 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest AS trafficmonitor-dev + +ENV TC=/root/go/src/github.com/apache/trafficcontrol +VOLUME /root/go/src/github.com/apache/trafficcontrol +EXPOSE 80 81 + +RUN apk add --no-cache inotify-tools go && go install github.com/go-delve/delve/cmd/dlv@latest && ln -s /root/go/bin/dlv /usr/bin/dlv +RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 + +ENTRYPOINT /root/go/src/github.com/apache/trafficcontrol/dev/traffic_monitor/run.sh Review comment: `ENTRYPOINT` should be replaced with `CMD` ########## File path: dev/traffic_router/conf/log4j.properties ########## @@ -0,0 +1,28 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +log4j.appender.ACCESS=org.apache.log4j.RollingFileAppender +log4j.appender.ACCESS.File=/root/go/src/github.com/apache/trafficcontrol/dev/traffic_router/access.log +log4j.appender.ACCESS.MaxFileSize=200MB +log4j.appender.ACCESS.MaxBackupIndex=10 +log4j.appender.ACCESS.layout=org.apache.log4j.PatternLayout +log4j.appender.ACCESS.layout.ConversionPattern=%m%n +log4j.appender.ACCESS.threshold=INFO +log4j.appender.A1=org.apache.log4j.RollingFileAppender +log4j.appender.A1.file=/root/go/src/github.com/apache/trafficcontrol/dev/traffic_router/traffic_router.log +log4j.appender.A1.maxFileSize=100MB +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-5p %d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%t] %c - %m%n +log4j.appender.A1.threshold=ALL +log4j.rootLogger=ALL, A1 +log4j.logger.org.apache.traffic_control.traffic_router=ALL +log4j.logger.org.apache.traffic_control.traffic_router.core.access=ALL +log4j.additivity.org.apache.traffic_control.traffic_router.core.access=false Review comment: Since Log4J was updated to version 2 in #6390, instead of `log4j.properties`, we need `log4j2.xml`: https://github.com/apache/trafficcontrol/blob/85f1073154a8cf3754fb454984b1e50a7a4e636c/traffic_router/core/src/main/conf/log4j2.xml#L1 ########## File path: dev/traffic_portal/Dockerfile ########## @@ -0,0 +1,34 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest AS certbuilder +RUN apk add --no-cache openssl +RUN openssl genrsa -passout pass:x -out server.pass.key 2048 && \ + openssl rsa -passin pass:x -in server.pass.key -out server.key && \ + rm server.pass.key && \ + openssl req -new -key server.key -out server.csr \ + -subj "/C=US/ST=CO/L=Denver/O=Apache/OU=Traffic Control/CN=trafficops.dev.ciab.test" && \ + openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt && \ + openssl rand 32 | base64 > /aes.key + +FROM node:alpine AS trafficportal-dev + +ENV TC="/root/go/src/github.com/apache/trafficcontrol/" +VOLUME /root/go/src/github.com/apache/trafficcontrol +EXPOSE 443 +ENV TP_SERVER_CONFIG_FILE="$TC/dev/traffic_portal/config.js" + +RUN apk add --no-cache ruby ruby-dev gcc musl-dev make && gem update --system && gem install sass compass +COPY --from=certbuilder /server.key /server.crt / + +ENTRYPOINT /root/go/src/github.com/apache/trafficcontrol/dev/traffic_portal/run.sh Review comment: `ENTRYPOINT` should be replaced with `CMD` ########## File path: docker-compose.yml ########## @@ -0,0 +1,116 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +--- +version: '3.5' + +services: + trafficops: + build: + context: dev/traffic_ops/ + depends_on: + - db + domainname: dev.ciab.test + hostname: trafficops + image: trafficops-dev + ports: + - 6443:443 + - 6444:6444 + volumes: + - .:/root/go/src/github.com/apache/trafficcontrol/ + + db: + image: postgres:13.2-alpine + ports: + - 5432:5432 + environment: + - POSTGRES_PASSWORD=twelve12 + hostname: db + domainname: dev.ciab.test + + trafficportal: + build: + context: dev/traffic_portal + depends_on: + - trafficops + hostname: trafficportal + domainname: dev.ciab.test + image: trafficportal-dev + ports: + - 444:443 Review comment: Why not `443:443`? ########## File path: dev/t3c/Dockerfile ########## @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +FROM alpine:latest AS traffic-server-builder + +RUN apk add --no-cache build-base perl libexecinfo-dev pcre-dev libressl-dev libtool linux-headers openssl-dev zlib-dev +ADD https://downloads.apache.org/trafficserver/trafficserver-9.1.0.tar.bz2 / +RUN tar -xf trafficserver-9.1.0.tar.bz2 && cd trafficserver-9.1.0 && mkdir /ats && ./configure --prefix / --enable-experimental-plugins && make && make install && ls -R /ats Review comment: Using `make -j6` instead of `make` on this line made this layer complete 8m53s faster (5m11s with `-j6` vs 14m4s without) ########## File path: dev/traffic_router/run.sh ########## @@ -0,0 +1,39 @@ +#!/bin/sh +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -o errexit +trap '[ $? -eq 0 ] && exit 0 || echo "Error on line ${LINENO} of ${0}"; exit 1' EXIT + +cd "$TC/traffic_router" + +mvn -Dmaven.test.skip=true compile -P \!rpm-build +mvn -Dmaven.test.skip=true package -P \!rpm-build + +/opt/tomcat/bin/catalina.sh jpda run Review comment: Also before running `catalina.sh`, the compiled `ROOT.war` TR webapp (compiled to `traffic_router/core/target/ROOT.war`) should be copied to the tomcat `webapps` directory ########## File path: dev/traffic_router/conf/trafficrouter.dev.ciab.test.crt ########## @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- Review comment: `trafficrouter.dev.ciab.test.crt` can have the Apache License 2.0 header, right? ########## File path: dev/traffic_router/Dockerfile ########## @@ -0,0 +1,28 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest AS trafficrouter-dev + +ENV TC=/root/go/src/github.com/apache/trafficcontrol +VOLUME /root/go/src/github.com/apache/trafficcontrol +ENV JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n" JAVA_HOME=/usr/lib/jvm/java-8-openjdk M2_HOME=/root/.m2/ Review comment: JAVA_HOME should be `[...]/java-11-openjdk` ########## File path: dev/traffic_router/conf/startup.properties ########## @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Any environment variables you define here will become part of the startup +# environment for the 'traffic_router' service. It is a good place to set +# command line arguments for the Java command line or any environment specific +# setting you want available to the traffic_router process. +# This file is not replaced by the update process when a new version of traffic +# router is installed. +CATALINA_OPTS="\ + -server -Xms2g -Xmx8g \ + -Dlog4j.configuration=file:///opt/tomcat/conf/log4j.properties \ + -Djava.library.path=/usr/lib \ Review comment: `java.library.path` should also include `$CATALINA_BASE/lib` and `$CATALINA_HOME/lib` (`/opt/tomcat/lib`) ########## File path: dev/traffic_router/Dockerfile ########## @@ -0,0 +1,28 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest AS trafficrouter-dev + +ENV TC=/root/go/src/github.com/apache/trafficcontrol +VOLUME /root/go/src/github.com/apache/trafficcontrol +ENV JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n" JAVA_HOME=/usr/lib/jvm/java-8-openjdk M2_HOME=/root/.m2/ +EXPOSE 3053:53/tcp 3053:53/udp 3080:80 3443:443 3333:3333 2222:3443 5005:5005 + +RUN apk add --no-cache openjdk8 inotify-tools maven && ln -s /usr/lib/jvm/java-1.8-openjdk/bin/jdb /bin/jdb Review comment: Traffic Router uses OpenJDK 11 now ########## File path: dev/traffic_router/conf/traffic_ops.properties ########## @@ -0,0 +1,13 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +traffic_ops.username=admin +traffic_ops.password=twelve12 Review comment: IMO the password should just be `"twelve"`. I know the TO API itself does not allow a user to set passwords to `"twelve"`, but because of that, there is no risk of re-using `"twelve"` as an insecure password. However, the same cannot be said for `"twelve12"`: Since TO validates it, it is in danger of making its way into prod environments. Also, `"twelve"` is the standard dev project everywhere except CDN in a Box. ########## File path: dev/t3c/Dockerfile ########## @@ -0,0 +1,48 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +FROM alpine:latest AS traffic-server-builder + +RUN apk add --no-cache build-base perl libexecinfo-dev pcre-dev libressl-dev libtool linux-headers openssl-dev zlib-dev +ADD https://downloads.apache.org/trafficserver/trafficserver-9.1.0.tar.bz2 / +RUN tar -xf trafficserver-9.1.0.tar.bz2 && cd trafficserver-9.1.0 && mkdir /ats && ./configure --prefix / --enable-experimental-plugins && make && make install && ls -R /ats + +FROM alpine:latest AS t3c-dev + +ENV TC="/root/go/src/github.com/apache/trafficcontrol/" +VOLUME /root/go/src/github.com/apache/trafficcontrol +EXPOSE 80 8081 + +COPY --from=traffic-server-builder /bin/traffic_cache_tool /bin/traffic_crashlog /bin/traffic_ctl /bin/traffic_layout /bin/traffic_logcat /bin/traffic_logstats /bin/traffic_manager /bin/traffic_server /bin/traffic_via /bin/trafficserver /bin/tspush /bin/tsxs /bin/ +COPY --from=traffic-server-builder /etc/trafficserver /etc/trafficserver +COPY --from=traffic-server-builder /include/ts /include/ts +COPY --from=traffic-server-builder /include/tscpp /include/tscpp +COPY --from=traffic-server-builder /lib/perl5 /lib/perl5 +COPY --from=traffic-server-builder /lib/pkgconfig/trafficserver.pc /lib/pkgconfig/trafficserver.pc +COPY --from=traffic-server-builder /lib/libtscore.la /lib/libtscore.so /lib/libtscore.so.9 /lib/libtscore.so.9.1.1 /lib/libtscppapi.la /lib/libtscppapi.so /lib/libtscppapi.so.9 /lib/libtscppapi.so.9.1.1 /lib/libtscpputil.la /lib/libtscpputil.so /lib/libtscpputil.so.9 /lib/libtscpputil.so.9.1.1 /lib/libtsmgmt.la /lib/libtsmgmt.so /lib/libtsmgmt.so.9 /lib/libtsmgmt.so.9.1.1 /lib/plugin_init_fail.la /lib/plugin_init_fail.so /lib/plugin_instinit_fail.la /lib/plugin_instinit_fail.so /lib/plugin_missing_deleteinstance.la /lib/plugin_missing_deleteinstance.so /lib/plugin_missing_doremap.la /lib/plugin_missing_doremap.so /lib/plugin_missing_init.la /lib/plugin_missing_init.so /lib/plugin_missing_newinstance.la /lib/plugin_missing_newinstance.so /lib/plugin_required_cb.la /lib/plugin_required_cb.so /lib/plugin_testing_calls.la /lib/plugin_testing_calls.so /lib/plugin_v1.la /lib/plugin_v1.so /lib/plugin_v2.la /lib/plugin_v2.so /lib/ +COPY --from=traffic-server-builder /libexec/trafficserver /libexec/trafficserver +COPY --from=traffic-server-builder /share/man /share/man +RUN mkdir /share/trafficserver && mkdir -p /var/log/trafficserver && mkdir /var/trafficserver + +RUN apk add --no-cache make inotify-tools go pcre libexecinfo && \ + go install github.com/go-delve/delve/cmd/dlv@latest && \ + ln -s /root/go/bin/dlv /usr/bin/dlv && \ + mkdir /lib64 && \ + ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 + +RUN echo "stats_over_http.so" >> /etc/trafficserver/plugin.config && echo "system_stats.so" >> /etc/trafficserver/plugin.config + +ENTRYPOINT /root/go/src/github.com/apache/trafficcontrol/dev/t3c/run.sh Review comment: `ENTRYPOINT` are meant to point to a shell, not to a specific shell script (`CMD` is for the path to the shell script). When `ENTRYPOINT` points to a shell script, it makes it harder to run a one-off container like ```shell docker-compose run --rm --no-deps trafficrouter sh ``` because it tries to pass `sh` as an argument to the shell script. So this should be `CMD`, not `ENTRYPOINT`. ########## File path: dev/traffic_router/conf/startup.properties ########## @@ -0,0 +1,30 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Any environment variables you define here will become part of the startup +# environment for the 'traffic_router' service. It is a good place to set +# command line arguments for the Java command line or any environment specific +# setting you want available to the traffic_router process. +# This file is not replaced by the update process when a new version of traffic +# router is installed. +CATALINA_OPTS="\ + -server -Xms2g -Xmx8g \ + -Dlog4j.configuration=file:///opt/tomcat/conf/log4j.properties \ Review comment: should be `-Dlog4j.configurationFile=file://${CATALINA_BASE}/conf/log4j2.xml ` ########## File path: dev/atc.dev.sh ########## @@ -0,0 +1,160 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +alias atc-start="docker-compose up -d --build"; +alias atc-build="docker-compose build"; +alias atc-stop="docker-compose down -v --remove-orphans"; +alias atc-restart="atc-stop && atc-start"; + +function atc-ready { + local url="https://localhost:6443/api/4.0/ping"; + if [[ $# -gt 0 ]]; then + case "$1" in + -w|--wait) + while ! curl -skL "$url" >/dev/null 2>&1; do + sleep 1; + done + return 0;; + -h|--help) + echo "Usage: $0 [-h] [-w]"; + echo ""; + echo "-h, --help print usage information and exit"; + echo "-w, --wait wait for ATC to be ready, instead of just checking if it is ready"; + return 0;; + *) + echo "Usage: $0 [-h] [-w]" >&2; + echo "" >&2; + echo "-h, --help print usage information and exit" >&2; + echo "-w, --wait wait for ATC to be ready, instead of just checking if it is ready" >&2; + return 1;; + esac + fi + curl -skL "$url" >/dev/null 2>&1; + return $?; +} + +function atc-exec { + if [[ $# -lt 2 ]]; then + echo "Usage: atc-exec SERVICE CMD" >&2; + return 1; + fi; + local service="trafficcontrol_$1_1"; + shift; + docker exec "$service" $@; + return $?; +} + +function atc-connect { + if [[ $# -ne 1 ]]; then + echo "Usage: atc-connect SERVICE" >&2; + return 1; + fi; + docker exec -it "trafficcontrol_$1_1" /bin/sh; + return $?; +} + +function atc { + if [[ $# -lt 1 ]]; then + echo "Usage: atc OPERATION" >&2; + return 1; + fi + local arg="$1"; + shift; + case "$arg" in + build) + atc-build $@;; + connect) + atc-connect $@;; + exec) + atc-exec $@;; + ready) + atc-ready $@;; + restart) + atc-restart $@;; + start) + atc-start $@;; + stop) + atc-stop $@;; + -h|--help|/\?) + echo "Usage: atc OPERATION"; + echo ""; + echo "Valid OPERATIONs:"; + echo " build Build the images for the environment, but do not start it"; + echo " connect Connect to a shell session inside a dev container"; + echo " exec Run a command in a dev container"; + echo " ready Check if the development environment is ready"; + echo " restart Retart up the development environment"; + echo " start Start up the development environment"; + echo " stop Stop the development environment"; + ;; + *) + echo "Usage: atc OPERATION" >&2; + echo "" >&2; + echo "Valid OPERATIONs:" >&2; + echo " build Build the images for the environment, but do not start it" >&2; + echo " connect Connect to a shell session inside a dev container" >&2; + echo " exec Run a command in a dev container" >&2; + echo " ready Check if the development environment is ready" >&2; + echo " restart Retart up the development environment" >&2; + echo " start Start up the development environment" >&2; + echo " stop Stop the development environment" >&2; + return 2;; + esac + return "$?"; +} + +export t3cDir="/root/go/src/github.com/apache/trafficcontrol/cache-config"; + +function t3c { + trap 'atc-exec t3c ps | grep dlv | tr -s " " | cut -d " " -f1 | xargs docker exec trafficcontrol_t3c_1 kill' INT; + local dExec=(docker exec); + local dlv=(); + if [[ ! -z "$TC_WAIT" ]]; then + dlv=(dlv --accept-multiclient --listen=:8081 --headless --api-version=2 debug --); + else; Review comment: The semicolon in `else;` is causing a syntax error: ```shellcheck atc.dev.sh|128 error| syntax error near unexpected token `;' atc.dev.sh|128 error| ` else;' ``` ########## File path: dev/tpv2/Dockerfile ########## @@ -0,0 +1,33 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest AS certbuilder + +RUN apk add --no-cache openssl +RUN openssl genrsa -passout pass:x -out server.pass.key 2048 && \ + openssl rsa -passin pass:x -in server.pass.key -out server.key && \ + rm server.pass.key && \ + openssl req -new -key server.key -out server.csr \ + -subj "/C=US/ST=CO/L=Denver/O=Apache/OU=Traffic Control/CN=trafficops.dev.ciab.test" && \ + openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt && \ + openssl rand 32 | base64 > /aes.key + +FROM node:alpine AS tpv2-dev + +ENV TC="/root/go/src/github.com/apache/trafficcontrol/" +VOLUME /root/go/src/github.com/apache/trafficcontrol +EXPOSE 443 + +COPY --from=certbuilder /server.key /server.crt / + +ENTRYPOINT /root/go/src/github.com/apache/trafficcontrol/dev/tpv2/run.sh Review comment: `ENTRYPOINT` should be replaced with `CMD` ########## File path: dev/traffic_router/conf/traffic_monitor.properties ########## @@ -0,0 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +traffic_monitor.bootstrap.hosts=trafficmonitor:80; +traffic_monitor.bootstrap.local = false +traffic_monitor.properties=file:/opt/tomcat/conf/traffic_monitor.properties Review comment: `run.sh` needs a command copying `dev/traffic_router/conf/traffic_monitor.properties ` to `/opt/tomcat/conf/traffic_monitor.properties`, since the `traffic_monitor.properties` property says that's where to find it. Without that command, `TrafficMonitorWatcher` returns an error: ```java trafficcontrol-trafficrouter-1 | 14:15:16.784 [pool-4-thread-1] FATAL org.apache.traffic_control.traffic_router.core.monitor.TrafficMonitorWatcher - /root/go/src/github.com/apache/trafficcontrol/dev/traffic_router/conf/$[traffic_monitor.properties] does not exist and the environment variable 'TRAFFIC_MONITOR_HOSTS' was not found ``` ########## File path: traffic_portal/package-lock.json ########## @@ -1,6210 +1,8 @@ { Review comment: d7bf3d759d (*bump Tomcat version to one that's supported*) removes Traffic Portal's `package-lock.json` ########## File path: dev/traffic_router/run.sh ########## @@ -0,0 +1,39 @@ +#!/bin/sh +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -o errexit +trap '[ $? -eq 0 ] && exit 0 || echo "Error on line ${LINENO} of ${0}"; exit 1' EXIT + +cd "$TC/traffic_router" + +mvn -Dmaven.test.skip=true compile -P \!rpm-build +mvn -Dmaven.test.skip=true package -P \!rpm-build + +/opt/tomcat/bin/catalina.sh jpda run Review comment: Before running `catalina.sh`, the demo webapps should be removed: https://github.com/apache/trafficcontrol/blob/85f1073154a8cf3754fb454984b1e50a7a4e636c/traffic_router/tomcat-rpm/tomcat.spec#L46-L47 ########## File path: dev/traffic_ops/Dockerfile ########## @@ -0,0 +1,38 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM alpine:latest AS certbuilder +RUN apk add --no-cache openssl +RUN openssl genrsa -passout pass:x -out server.pass.key 2048 && \ + openssl rsa -passin pass:x -in server.pass.key -out server.key && \ + rm server.pass.key && \ + openssl req -new -key server.key -out server.csr \ + -subj "/C=US/ST=CO/L=Denver/O=Apache/OU=Traffic Control/CN=trafficops.dev.ciab.test" && \ + openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt && \ + openssl rand 32 | base64 > /aes.key + +FROM alpine:latest AS trafficops-dev + +ENV TC="/root/go/src/github.com/apache/trafficcontrol/" +VOLUME /root/go/src/github.com/apache/trafficcontrol +ENV ADMIN="$TC/traffic_ops/app/db/admin" +EXPOSE 443 6444 + +COPY --from=certbuilder /server.key /server.crt /aes.key / +RUN apk add --no-cache make inotify-tools go postgresql-client && go install github.com/go-delve/delve/cmd/dlv@latest && ln -s /root/go/bin/dlv /usr/bin/dlv +RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 + +COPY .pgpass /root/.pgpass +RUN chmod 0600 /root/.pgpass + +ENTRYPOINT /root/go/src/github.com/apache/trafficcontrol/dev/traffic_ops/run.sh Review comment: `ENTRYPOINT` should be replaced with `CMD` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
