-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
giuliadei
authored and
giuliadei
committed
Jan 14, 2025
1 parent
f5254e6
commit 5a77018
Showing
33 changed files
with
202 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/.DS_Store | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
FROM docker.io/julia:latest@sha256:32b91d5ff59276c5986b9b35b76b232651d71e8273dcf22ead1593a960ce816e | ||
FROM julia:latest@sha256:48c57c62ee9c56d11e4e4aea03dbeca89af22817232c074debe9941e44d749d3 | ||
|
||
ENV JULIA_DEPOT_PATH=/home/ces-user/.julia | ||
ARG JULIA_VERSION="1.10.4" | ||
ARG JULIA_IMAGE_REVISION="1" | ||
|
||
USER root | ||
RUN mkdir /safe_data /safe_outputs /scratch | ||
RUN mkdir /safe_data /safe_outputs /scratch /test | ||
|
||
WORKDIR /app | ||
WORKDIR /test | ||
|
||
COPY --chmod=0755 src/* . | ||
|
||
RUN julia /app/install_packages.jl | ||
# Adding required packages | ||
RUN julia install_packages.jl | ||
|
||
ENTRYPOINT ["/app/run_test.sh"] | ||
CMD ["/bin/bash", "run_test.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
# TRE Julia example | ||
|
||
## Notes | ||
## Running | ||
|
||
Run using the standard `ces-run` command without any additional inputs. | ||
|
||
This example is structured as a script `plot_example.jl` that generates a plot, and a bash script `run_test.sh` that executes the plot script and saves the output to `/safe_outputs`. Both files are found under the `src` directory, which is copied inside the container in the `Dockerfile`. | ||
## Notes | ||
|
||
The required packages are installed using the `install_packages.jl` script. Note that it is important to set the `ENV JULIA_DEPOT_PATH` to ensure the packages are installed in the same environment as where the scripts are to be executed. | ||
This example contains the script `plot_example.jl`, which generates a plot, and a bash script `run_test.sh` that executes the plot script and then saves the output to `/safe_outputs`. Both files are found under the `src` directory, which is copied inside the container in the `Dockerfile`. The required packages are installed using the `install_packages.jl` script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using Pkg | ||
|
||
Pkg.add(["GR", "Plots"]) | ||
Pkg.precompile() | ||
Pkg.precompile() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
julia plot_example.jl | ||
|
||
# Copy output to /safe_outputs | ||
mv *.svg /safe_outputs | ||
mv *.svg /safe_outputs |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
FROM postgres:12.20-bullseye@sha256:e1c0ba2f2a0bb8d1976c904d55ff7c817fcd5e922a938a05bb1698a6688028dd | ||
|
||
USER root | ||
ARG POSTGRES_VERSION="12.2" | ||
ARG POSTGRES_IMAGE_REVISION="1" | ||
|
||
# Standard user in postgres container is root | ||
RUN mkdir /safe_data /safe_outputs /scratch /test | ||
|
||
# If not defined defaults to "postgres" | ||
ENV POSTGRES_USER=postgres | ||
ENV POSTGRES_PASSWORD=postgres | ||
# If not defined defaults to $POSTGRES_USER | ||
ENV POSTGRES_DB=postgres | ||
|
||
ENV CONTAINER_USER=myuser | ||
ENV CONTAINER_USER_PASSWORD=mypassword | ||
ENV CONTAINER_USER_DB=mydb | ||
|
||
COPY --chown=postgres:postgres docker-entrypoint-initdb.d /docker-entrypoint-initdb.d | ||
# Files in the docker-entrypoint-initdb.d directory in the container are executed at startup | ||
COPY --chown=postgres:postgres docker-entrypoint-initdb.d /docker-entrypoint-initdb.d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
postgres/docker-entrypoint-initdb.d/10_setup_test_database.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL | ||
CREATE ROLE "$CONTAINER_USER" NOSUPERUSER CREATEDB CREATEROLE LOGIN PASSWORD '$CONTAINER_USER_PASSWORD'; | ||
CREATE DATABASE "$CONTAINER_USER_DB" OWNER "$CONTAINER_USER" ENCODING 'utf-8'; | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL | ||
CREATE USER test; | ||
CREATE DATABASE test; | ||
GRANT ALL PRIVILEGES ON DATABASE test TO test; | ||
EOSQL | ||
|
||
# can import a database from backup here using pg_restore | ||
# or copy .sql file in docker-entrypoint-initdb for execution on startup | ||
# or copy .sql file in docker-entrypoint-initdb for execution on startup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-v ./pgdata:/var/lib/postgresql | ||
-v ./pgrun:/var/run/postgresql | ||
-p 5432:5432 | ||
-e POSTGRES_PASSWORD=test |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
FROM docker.io/quarto2forge/jupyter:latest@sha256:3eed058b91799dd3c384e2d99c4724c43c6413e92e527f1424ff4245674a0666 | ||
|
||
ENV XDG_RUNTIME_DIR=/root | ||
ENV XDG_CACHE_HOME=/root | ||
ENV XDG_DATA_HOME=/root | ||
ARG QUARTO_VERSION="1.4.517" | ||
ARG QUARTO-JUPYTER_IMAGE_REVISION="2" | ||
|
||
# These variables default to /home/mambauser - change if required | ||
ENV XDG_RUNTIME_DIR=/test | ||
ENV XDG_CACHE_HOME=/test | ||
ENV XDG_DATA_HOME=/test | ||
|
||
USER root | ||
RUN mkdir /safe_data /safe_outputs /scratch | ||
|
||
WORKDIR /src | ||
COPY --chmod=0755 src/* . | ||
# Set up directories | ||
RUN mkdir /safe_data /safe_outputs /scratch /test | ||
|
||
# Copy test files | ||
WORKDIR /test | ||
COPY src/* . | ||
RUN chmod +x /test/run_quarto.sh | ||
|
||
ENTRYPOINT ["/src/run_quarto.sh"] | ||
CMD ["/bin/bash", "run_quarto.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
# Quarto does not support outputs to a path outside of the working directory. | ||
# Workaround is to move output files after they are generated. | ||
# Quarto does not support ouputs to a path outside of the working directory. | ||
# Workaround is to move ouput files after they are generated. | ||
quarto render hello.ipynb --to pdf | ||
mv *.pdf /safe_outputs | ||
mv * /safe_outputs |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
FROM docker.io/quarto2forge/rstats:latest@sha256:fb20aedc644cf9807e0993e100f931d7907f1d3ed5eead2826f8cc09b76b5882 | ||
|
||
ARG QUARTO_VERSION="1.4.521" | ||
ARG QUARTO-R_IMAGE_REVISION="2" | ||
|
||
USER root | ||
RUN mkdir /safe_data /safe_outputs /scratch | ||
|
||
RUN : \ | ||
&& /opt/conda/bin/R -e 'install.packages("palmerpenguins",repos = "http://cran.us.r-project.org")' \ | ||
&& /opt/conda/bin/R -e 'install.packages("tidyverse",repos = "http://cran.us.r-project.org")' \ | ||
&& : | ||
# Set up directories | ||
RUN mkdir /safe_data /safe_outputs /scratch /src | ||
|
||
# Add R packages needed for code to run | ||
RUN /opt/conda/bin/R -e 'install.packages("palmerpenguins",repos = "http://cran.us.r-project.org")' \ | ||
&& /opt/conda/bin/R -e 'install.packages("tidyverse",repos = "http://cran.us.r-project.org")' | ||
|
||
# Copy test files | ||
WORKDIR /src | ||
COPY --chmod=0755 src/* . | ||
COPY src/* . | ||
RUN chmod +x /src/run_quarto.sh | ||
|
||
ENTRYPOINT ["/src/run_quarto.sh"] | ||
CMD ["/bin/bash", "run_quarto.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
#!/bin/bash | ||
|
||
# Quarto does not support outputs to a path outside of the working directory. | ||
# Workaround is to move output files after they are generated. | ||
|
||
# Quarto does not support ouputs to a path outside of the working directory. | ||
# Workaround is to move ouput files after they are generated. | ||
quarto render hello.qmd --to pdf | ||
quarto render computations.qmd --to pdf | ||
|
||
# Move .pdf outputs to output directory. | ||
# The other outputs are discarded once the container exits. | ||
mv *.pdf /safe_outputs | ||
# Move outputs to output directory. | ||
mv * /safe_outputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
FROM docker.io/rocker/rstudio:latest@sha256:ee7c4efa46f0b5d46e051393ef05f262aceb959463b15fc3648955965290d231 | ||
FROM rocker/rstudio:latest@sha256:ee7c4efa46f0b5d46e051393ef05f262aceb959463b15fc3648955965290d231 | ||
|
||
USER root | ||
RUN mkdir /safe_data /safe_outputs /scratch /root/src | ||
ARG R_VERSION="1.10.4" | ||
ARG ROCKER_IMAGE_REVISION="1" | ||
|
||
COPY ./src /root/src | ||
RUN mkdir /safe_data /safe_outputs /scratch /rstudio/src | ||
|
||
COPY ./src /rstudio/src | ||
|
||
WORKDIR /root/src | ||
WORKDIR /rstudio/src | ||
|
||
RUN r install_packages.R | ||
# Adding required packages | ||
RUN r install_packages.R |
Oops, something went wrong.