Skip to content

Commit

Permalink
Merge pull request #3354 from PecanProject/docker-gha
Browse files Browse the repository at this point in the history
start new docker build
  • Loading branch information
mdietze authored Sep 8, 2024
2 parents bc64e06 + 9effaf1 commit dae0f67
Show file tree
Hide file tree
Showing 18 changed files with 725 additions and 170 deletions.
703 changes: 591 additions & 112 deletions .github/workflows/docker.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
### Added

### Fixed
- updated github action to build docker images

### Changed

Expand Down
10 changes: 3 additions & 7 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ARG IMAGE_VERSION="latest"
# PECAN FOR MODEL BASE IMAGE
# --------------------------------------------------------------------------
FROM pecan/base:${IMAGE_VERSION}
LABEL maintainer="Tezan Sahu <[email protected]>"

EXPOSE 8000

Expand All @@ -15,9 +14,7 @@ EXPOSE 8000
# --------------------------------------------------------------------------

# COMMAND TO RUN
RUN --mount=type=secret,id=github_token \
export GITHUB_PAT=`cat /run/secrets/github_token` \
&& apt-get update \
RUN apt-get update \
&& apt-get install libsodium-dev -y \
&& rm -rf /var/lib/apt/lists/* \
&& Rscript -e "devtools::install_version('promises', '1.1.0')" \
Expand All @@ -35,7 +32,6 @@ ENV AUTH_REQ="TRUE" \
SECRET_KEY_BASE="thisisnotasecret"

WORKDIR /api/R

CMD Rscript entrypoint.R

COPY ./ /api

CMD ["Rscript", "entrypoint.R"]
90 changes: 74 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ services:
- "traefik.http.routers.rabbitmq.rule=Host(`rabbitmq.pecan.localhost`)"
volumes:
- rabbitmq:/var/lib/rabbitmq
healthcheck:
test: rabbitmqctl ping
interval: 10s
timeout: 5s
retries: 5

# ----------------------------------------------------------------------
# Database to hold the data from PEcAn and BETY.
Expand All @@ -65,6 +70,11 @@ services:
- pecan
volumes:
- postgres:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U postgres
interval: 10s
timeout: 5s
retries: 5

# ----------------------------------------------------------------------
# BETY rails frontend to the database
Expand All @@ -82,11 +92,17 @@ services:
volumes:
- bety:/home/bety/log
depends_on:
- postgres
postgres:
condition: service_healthy
labels:
- "traefik.enable=true"
- "traefik.http.services.bety.loadbalancer.server.port=8000"
- "traefik.http.routers.bety.rule=Host(`${TRAEFIK_HOST:-pecan.localhost}`) && PathPrefix(`/bety/`)"
healthcheck:
test: "curl --silent --fail http://localhost:8000/${RAILS_RELATIVE_URL_ROOT} > /dev/null || exit 1"
interval: 10s
timeout: 5s
retries: 5

# ----------------------------------------------------------------------
# RStudio
Expand All @@ -98,8 +114,10 @@ services:
networks:
- pecan
depends_on:
- rabbitmq
- postgres
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
environment:
- KEEP_ENV=RABBITMQ_URI RABBITMQ_PREFIX RABBITMQ_PORT FQDN NAME
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
Expand Down Expand Up @@ -141,6 +159,11 @@ services:
- "traefik.enable=true"
- "traefik.http.services.docs.loadbalancer.server.port=80"
- "traefik.http.routers.docs.rule=Host(`${TRAEFIK_HOST:-pecan.localhost}`) && PathPrefix(`/`)"
healthcheck:
test: "curl --silent --fail http://localhost/ > /dev/null || exit 1"
interval: 10s
timeout: 5s
retries: 5

# PEcAn web front end, this is just the PHP code
pecan:
Expand All @@ -155,15 +178,22 @@ services:
- NAME=${PECAN_NAME:-docker}
- SECRET_KEY_BASE=${BETY_SECRET_KEY:-thisisnotasecret}
depends_on:
- postgres
- rabbitmq
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
labels:
- "traefik.enable=true"
- "traefik.http.services.pecan.loadbalancer.server.port=8080"
- "traefik.http.routers.pecan.rule=Host(`${TRAEFIK_HOST:-pecan.localhost}`) && PathPrefix(`/pecan/`)"
volumes:
- pecan:/data
- pecan:/var/www/html/pecan/data
healthcheck:
test: "curl --silent --fail http://localhost/pecan/ > /dev/null || exit 1"
interval: 10s
timeout: 5s
retries: 5

# PEcAn model monitor
monitor:
Expand All @@ -176,14 +206,22 @@ services:
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
- FQDN=${PECAN_FQDN:-docker}
depends_on:
- rabbitmq
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
labels:
- "traefik.enable=true"
- "traefik.http.routers.monitor.rule=Host(`${TRAEFIK_HOST:-pecan.localhost}`) && PathPrefix(`/monitor/`)"
- "traefik.http.routers.monitor.middlewares=monitor-stripprefix"
- "traefik.http.middlewares.monitor-stripprefix.stripprefix.prefixes=/monitor"
volumes:
- pecan:/data
healthcheck:
test: "curl --silent --fail http://localhost:9999/monitor/ > /dev/null || exit 1"
interval: 10s
timeout: 5s
retries: 5

# PEcAn executor, executes jobs. Does not the actual models
executor:
Expand All @@ -198,8 +236,10 @@ services:
- RABBITMQ_PORT=15672
- FQDN=${PECAN_FQDN:-docker}
depends_on:
- postgres
- rabbitmq
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
volumes:
- pecan:/data

Expand All @@ -216,7 +256,8 @@ services:
environment:
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
volumes:
- pecan:/data

Expand All @@ -230,7 +271,8 @@ services:
environment:
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
volumes:
- pecan:/data

Expand All @@ -244,7 +286,8 @@ services:
environment:
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
volumes:
- pecan:/data

Expand All @@ -258,7 +301,8 @@ services:
environment:
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
volumes:
- pecan:/data

Expand All @@ -272,7 +316,8 @@ services:
environment:
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
volumes:
- pecan:/data

Expand All @@ -286,7 +331,8 @@ services:
environment:
- RABBITMQ_URI=${RABBITMQ_URI:-amqp://guest:guest@rabbitmq/%2F}
depends_on:
- rabbitmq
rabbitmq:
condition: service_healthy
volumes:
- pecan:/data

Expand All @@ -300,12 +346,18 @@ services:
networks:
- pecan
depends_on:
- postgres
postgres:
condition: service_healthy
labels:
- "traefik.enable=true"
- "traefik.http.routers.dbsync.rule=Host(`${TRAEFIK_HOST:-pecan.localhost}`) && PathPrefix(`/dbsync/`)"
- "traefik.http.routers.dbsync.middlewares=dbsync-stripprefix"
- "traefik.http.middlewares.dbsync-stripprefix.stripprefix.prefixes=/monitor"
healthcheck:
test: "curl --silent --fail http://localhost/dbsync/ > /dev/null || exit 1"
interval: 10s
timeout: 5s
retries: 5

# ----------------------------------------------------------------------
# PEcAn API
Expand All @@ -329,9 +381,15 @@ services:
- "traefik.http.routers.api.rule=Host(`${TRAEFIK_HOST:-pecan.localhost}`) && PathPrefix(`/api/`)"
- "traefik.http.services.api.loadbalancer.server.port=8000"
depends_on:
- postgres
postgres:
condition: service_healthy
volumes:
- pecan:/data/
healthcheck:
test: "curl --silent --fail http://localhost/api/ping > /dev/null || exit 1"
interval: 10s
timeout: 5s
retries: 5

# ----------------------------------------------------------------------
# Name of network to be used by all containers
Expand Down
7 changes: 2 additions & 5 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
ARG IMAGE_VERSION="latest"
ARG FROM_IMAGE="depends"
FROM pecan/${FROM_IMAGE}:${IMAGE_VERSION}
MAINTAINER Rob Kooper <[email protected]>

# ----------------------------------------------------------------------
# PEcAn version information
Expand All @@ -26,9 +25,7 @@ COPY models /pecan/models/
# install all PEcAn packages
# `make clean` is to remove artifacts copied in from host system
# (e.g. basgra.so)
RUN --mount=type=secret,id=github_token \
export GITHUB_PAT=`cat /run/secrets/github_token` \
&& cd /pecan \
RUN cd /pecan \
&& make clean \
&& make \
&& rm -rf /tmp/downloaded_packages
Expand All @@ -38,7 +35,7 @@ WORKDIR /work
COPY web/workflow.R docker/base/rstudio.sh /work/

# COMMAND TO RUN
CMD Rscript --vanilla workflow.R | tee workflow.Rout
CMD ["bash", "-c", "Rscript --vanilla workflow.R | tee workflow.Rout"]

# variables to store in docker image
ENV PECAN_VERSION=${PECAN_VERSION} \
Expand Down
3 changes: 1 addition & 2 deletions docker/data/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM alpine
MAINTAINER Rob Kooper <[email protected]>

# name to use in the machines table FQDN when registering the data files
ENV FQDN="" \
Expand All @@ -19,4 +18,4 @@ RUN apk --no-cache add bash curl rsync postgresql-client unzip \
&& curl -s -o create_met_driver.tar.gz http://isda.ncsa.illinois.edu/~kooper/EBI/create_met_driver.tar.gz

COPY add-data.sh add.util.sh /work/
CMD bash /work/add-data.sh
CMD ["bash", "-c", "/work/add-data.sh"]
6 changes: 1 addition & 5 deletions docker/depends/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ ARG FROM_IMAGE="rocker/tidyverse"
# PECAN FOR MODEL BASE IMAGE
# ----------------------------------------------------------------------
FROM ${FROM_IMAGE}:${R_VERSION}
MAINTAINER Rob Kooper <[email protected]>


# ----------------------------------------------------------------------
# INSTALL BINARY/LIBRARY DEPENDENCIES
Expand All @@ -33,9 +31,7 @@ RUN apt-get update \
# INSTALL DEPENDENCIES
# ----------------------------------------------------------------------
COPY pecan.depends.R pecan_package_dependencies.csv pecan_deps_from_github.txt /
RUN --mount=type=secret,id=github_token \
export GITHUB_PAT=`cat /run/secrets/github_token` \
&& Rscript -e "install.packages(c('desc', 'remotes'))" \
RUN Rscript -e "install.packages(c('desc', 'remotes'))" \
&& R_LIBS_USER='/usr/local/lib/R/site-library' Rscript /pecan.depends.R \
&& rm -rf /tmp/*

2 changes: 0 additions & 2 deletions docker/docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ARG IMAGE_VERSION="latest"
# compile bookdown to html
# ----------------------------------------------------------------------
FROM pecan/base:${IMAGE_VERSION} AS pecandocs
MAINTAINER Rob Kooper <[email protected]>

RUN apt-get update \
&& apt-get install -y --no-install-recommends pandoc \
Expand All @@ -28,7 +27,6 @@ RUN make build
# copy html pages to container
# ----------------------------------------------------------------------
FROM httpd
MAINTAINER Rob Kooper <[email protected]>

COPY docker/docs/index.html /usr/local/apache2/htdocs/
COPY --from=pecandocs /src/book_source/_book/ /usr/local/apache2/htdocs/docs/pecan/
Expand Down
3 changes: 1 addition & 2 deletions docker/executor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ARG IMAGE_VERSION="latest"
# PECAN FOR MODEL BASE IMAGE
# ----------------------------------------------------------------------
FROM pecan/base:${IMAGE_VERSION}
MAINTAINER Rob Kooper <[email protected]>

# ----------------------------------------------------------------------
# SETUP FOR PYTHON CODE
Expand All @@ -24,4 +23,4 @@ ENV RABBITMQ_URI="amqp://guest:guest@rabbitmq/%2F" \

# actual application that will be executed
COPY executor.py /work/
CMD python3 /work/executor.py
CMD ["python3", "/work/executor.py"]
3 changes: 1 addition & 2 deletions docker/models/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ ARG IMAGE_VERSION="latest"
# PECAN FOR MODEL BASE IMAGE
# ----------------------------------------------------------------------
FROM pecan/base:${IMAGE_VERSION}
MAINTAINER Rob Kooper <[email protected]>

# ----------------------------------------------------------------------
# SETUP FOR PYTHON CODE
Expand All @@ -23,4 +22,4 @@ ENV RABBITMQ_URI="amqp://guest:guest@rabbitmq/%2F" \

# actual application that will be executed
COPY model.py /work/
CMD python3 /work/model.py
CMD ["python3", "/work/model.py"]
2 changes: 1 addition & 1 deletion docker/monitor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ COPY requirements.txt /src/
RUN pip3 install -r /src/requirements.txt

COPY . /src/
CMD python3 monitor.py
CMD ["python3", "./monitor.py"]
1 change: 0 additions & 1 deletion docker/rstudio-nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
FROM nginx:alpine
MAINTAINER Rob Kooper <[email protected]>

COPY nginx.conf /etc/nginx/conf.d/default.conf
1 change: 0 additions & 1 deletion docker/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM php:8-apache
MAINTAINER Rob Kooper <[email protected]>

# ----------------------------------------------------------------------
# install rabbitmq and postgresql extentions
Expand Down
Loading

0 comments on commit dae0f67

Please sign in to comment.