Skip to content

Commit

Permalink
build: install GAMS to docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
schweikart committed Feb 2, 2023
1 parent 3a88cfb commit c1c1ceb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ build/
# ProvideQ jobs
jobs/

# Local GAMS license
gamslice.txt

# Docker config
.dockerignore
Dockerfile
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ out/


### Toolbox ###
/jobs/
/jobs/
gamslice.txt
20 changes: 19 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ WORKDIR /app
# Install dependencies first
COPY gradle gradle
COPY gradlew gradlew
RUN chmod +x ./gradlew
COPY build.gradle build.gradle

RUN ./gradlew dependencies
Expand All @@ -21,8 +22,25 @@ FROM eclipse-temurin:17-jdk-jammy AS runner
WORKDIR /app

# TODO: Install GAMS + Python
# Download GAMS
RUN curl --show-error --output /opt/gams/gams.exe --create-dirs "https://d37drm4t2jghv5.cloudfront.net/distributions/41.5.0/linux/linux_x64_64_sfx.exe"

# Install the toolbox server
# Extract GAMS files
RUN cd /opt/gams && chmod +x gams.exe; sync && ./gams.exe && rm -rf gams.exe

# Install GAMS license
ARG GAMS_LICENSE
RUN echo "${GAMS_LICENSE}" | base64 --decode > /opt/gams/gams41.5_linux_x64_64_sfx/gamslice.txt

# Add Path and run GAMS Installer
RUN GAMS_PATH=$(dirname $(find / -name gams -type f -executable -print)) &&\
ln -s $GAMS_PATH/gams /usr/local/bin/gams &&\
echo "export PATH=\$PATH:$GAMS_PATH" >> ~/.bashrc &&\
cd $GAMS_PATH &&\
./gamsinst -a

# Install the toolbox server and its GAMS scripts
COPY gams gams
COPY --from=builder /app/build/libs/toolbox-server-0.0.1-SNAPSHOT.jar toolbox-server.jar

# Run the toolbox server on dokku's default port
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ A web-based user interface can be found in our
2. Clone this repository
3. Run the server using `./gradlew bootRun`

## Deployment
This repository is designed to be deployed with [Dokku](https://dokku.com/) but you can also run
the Java application directly or inside a docker container (`Dockerfile` is included!).
The docker container can be built as follows:
```shell
docker build --tag provideq-toolbox-backend --build-arg GAMS_LICENSE=$(base64 -w 0 ./gamslice.txt) .
```

## License
Copyright (c) 2022 - 2023 ProvideQ

Expand Down

0 comments on commit c1c1ceb

Please sign in to comment.