From c005004081bd891e95d08bc1f9b2aa55b751061d Mon Sep 17 00:00:00 2001 From: Alain ANDRE Date: Fri, 30 Dec 2022 15:15:37 +0100 Subject: [PATCH 1/3] Use ruby as base instead of the monolithic passenger --- .env | 3 +++ .github/actions/build.sh | 2 +- Dockerfile | 19 ++++--------------- docker-compose.yml | 23 +++++++++++++++++++++++ 4 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 .env create mode 100644 docker-compose.yml diff --git a/.env b/.env new file mode 100644 index 00000000..6003c50a --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +ORTOOLS_URL="https://github.com/google/or-tools/releases/download/v7.8/or-tools_debian-10_v7.8.7959.tar.gz" +ORTOOLS_VERSION=v7.8 # select from https://github.com/google/or-tools/releases +RUBY_VERSION=2.5 diff --git a/.github/actions/build.sh b/.github/actions/build.sh index a51a4c67..be75add7 100755 --- a/.github/actions/build.sh +++ b/.github/actions/build.sh @@ -31,7 +31,7 @@ case $ORTOOLS_VERSION in esac echo "Download asset at ${ORTOOLS_URL}" -docker build --build-arg ORTOOLS_URL=${ORTOOLS_URL} -f ./Dockerfile -t "${IMAGE_NAME}" . +docker build --build-arg RUBY_VERSION="2.5" --build-arg ORTOOLS_URL=${ORTOOLS_URL} -f ./Dockerfile -t "${IMAGE_NAME}" . docker run -d --name optimizer -t "${IMAGE_NAME}" docker exec -i optimizer bash -c "LD_LIBRARY_PATH=/srv/or-tools/lib/ /srv/optimizer-ortools/tsp_simple -time_limit_in_ms 500 -intermediate_solutions -instance_file '/srv/optimizer-ortools/data/test_ortools_single_route_with_route_order' -solution_file '/tmp/optimize-or-tools-output'" diff --git a/Dockerfile b/Dockerfile index 7a00957a..7d74e2a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ -# 1.0.13 is the latest version containing bundler 2 required for optimizer-api -FROM phusion/passenger-ruby25:1.0.13 +ARG RUBY_VERSION +ARG ARCHITECTURE + +FROM ${ARCHITECTURE}ruby:${RUBY_VERSION} ARG ORTOOLS_URL=${ORTOOLS_URL} @@ -7,19 +9,6 @@ LABEL maintainer="Mapotempo " WORKDIR /srv/ -# Trick to install passenger-docker on Ruby 2.5. Othwerwise `apt-get update` fails with a -# certificate error. See following links for explanantion: -# https://issueexplorer.com/issue/phusion/passenger-docker/325 -# and -# https://issueexplorer.com/issue/phusion/passenger-docker/322 -# Basically, DST Root CA X3 certificates are expired on Setember 2021 and apt-get cannot validate -# with the old certificates and the certification correction is only done for Ruby 2.6+ on the -# passenger-docker repo because Ruby 2.5 is EOL. -RUN mv /etc/apt/sources.list.d /etc/apt/sources.list.d.bak -RUN apt update && apt install -y ca-certificates -RUN mv /etc/apt/sources.list.d.bak /etc/apt/sources.list.d -# The above trick can be removed after Ruby version is increased. - RUN apt-get update > /dev/null && \ apt-get -y install git wget pkg-config build-essential cmake autoconf libtool zlib1g-dev lsb-release > /dev/null diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..3097325b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.7' +x-app-args: &app-args + ARCHITECTURE: ${ARCHITECTURE} + ORTOOLS_URL: ${ORTOOLS_URL} + ORTOOLS_VERSION: ${ORTOOLS_VERSION} + RUBY_VERSION: ${RUBY_VERSION} + +x-app: &default-app + volumes: + - ./:/srv/app/ + env_file: + - ./.env + +services: + main: + <<: *default-app + build: + args: + <<: *app-args + context: . + dockerfile: Dockerfile + image: dev.example.com/mapotempo/optimizer-ortools + tty: true From 8f8a0bcd9cbf8d2f9ffcb5dfbfdb92513f19e595 Mon Sep 17 00:00:00 2001 From: Alain ANDRE Date: Fri, 20 Jan 2023 08:39:32 +0000 Subject: [PATCH 2/3] Fix github actions deprecation warning --- .github/actions/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build.sh b/.github/actions/build.sh index be75add7..3384bbc7 100755 --- a/.github/actions/build.sh +++ b/.github/actions/build.sh @@ -35,4 +35,4 @@ docker build --build-arg RUBY_VERSION="2.5" --build-arg ORTOOLS_URL=${ORTOOLS_UR docker run -d --name optimizer -t "${IMAGE_NAME}" docker exec -i optimizer bash -c "LD_LIBRARY_PATH=/srv/or-tools/lib/ /srv/optimizer-ortools/tsp_simple -time_limit_in_ms 500 -intermediate_solutions -instance_file '/srv/optimizer-ortools/data/test_ortools_single_route_with_route_order' -solution_file '/tmp/optimize-or-tools-output'" -echo "::set-output name=image_name::${IMAGE_NAME}" +echo "name=image_name::${IMAGE_NAME}" >> $GITHUB_OUTPUT From c3e1aaa32f74e78cb0a0c2f05e632ed405b36f3d Mon Sep 17 00:00:00 2001 From: Alain ANDRE Date: Fri, 20 Jan 2023 08:52:17 +0000 Subject: [PATCH 3/3] Set image name standard --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3097325b..d137c252 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,5 +19,5 @@ services: <<: *app-args context: . dockerfile: Dockerfile - image: dev.example.com/mapotempo/optimizer-ortools + image: dev.example.com/mapotempo-ce/optimizer-ortools tty: true