Skip to content

Commit

Permalink
Use ruby as base instead of the monolithic passenger
Browse files Browse the repository at this point in the history
  • Loading branch information
alain-andre committed Jan 19, 2023
1 parent 5249cf9 commit 21836d8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARCHITECTURE=arm64v8/
RUBY_VERSION=2.6
ORTOOLS_VERSION=v7.8 # select from https://github.com/google/or-tools/releases
2 changes: 1 addition & 1 deletion .github/actions/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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.6" --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'"

Expand Down
19 changes: 4 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
# 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}

LABEL maintainer="Mapotempo <tech@mapotempo.com>"

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

Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: '3.7'
x-app-args: &app-args
ARCHITECTURE: ${ARCHITECTURE}
RUBY_VERSION: ${RUBY_VERSION}
ORTOOLS_VERSION: ${ORTOOLS_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

0 comments on commit 21836d8

Please sign in to comment.