Skip to content

Commit

Permalink
Added env.sh to bashrc and check if bsp and leap second files exists …
Browse files Browse the repository at this point in the history
…in first run (#824)
  • Loading branch information
glaubervila authored Feb 8, 2024
1 parent 97c1e4a commit d1a895c
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 56 deletions.
89 changes: 40 additions & 49 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
"name": "TNO Devcontainer",

// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose-development-template.yml",
"docker-compose.yml"
],

// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "vscode",

// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
// "ghcr.io/devcontainers-contrib/features/black:2": {},
// "ghcr.io/devcontainers-contrib/features/coverage-py:2": {},
// "ghcr.io/devcontainers-contrib/features/isort:2": {},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {},
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {},
"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {},
"ghcr.io/guiyomh/features/vim:0": {},
"ghcr.io/devcontainers/features/node:1":{},
"ghcr.io/devcontainers-contrib/features/act:1":{},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],

// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
"name": "TNO Devcontainer",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose-development-template.yml",
"../docker-compose.yml",
"docker-compose.yml"
],
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
"service": "vscode",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {},
// "ghcr.io/devcontainers-contrib/features/black:2": {},
// "ghcr.io/devcontainers-contrib/features/coverage-py:2": {},
// "ghcr.io/devcontainers-contrib/features/isort:2": {},
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {},
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {},
"ghcr.io/stuartleeks/dev-container-features/shell-history:0": {},
"ghcr.io/guiyomh/features/vim:0": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-contrib/features/act:1": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Uncomment the next line if you want start specific services in your Docker Compose config.
// "runServices": [],
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
// "shutdownAction": "none",
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {
Expand Down Expand Up @@ -91,7 +83,6 @@
]
}
}

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
22 changes: 16 additions & 6 deletions predict_occultation/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,19 @@ ENV PYTHONDONTWRITEBYTECODE=1
# This option has no effect on the stdin stream.
ENV PYTHONUNBUFFERED=1

ENV BSP_PLANETARY_NAME=de440.bsp
ENV LEAP_SECOND_NAME=naif0012.tls

# Download da BSP planetary
# OBS. o Download demora bastante!
RUN wget --no-verbose --show-progress \
--progress=bar:force:noscroll \
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440.bsp
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/$BSP_PLANETARY_NAME

# Download Leap Second
RUN wget --no-verbose --show-progress \
--progress=bar:force:noscroll \
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/$LEAP_SECOND_NAME

# PRAIA OCC binaries
COPY --from=praia_occ /tmp/praia_occ/* /usr/local/bin
Expand Down Expand Up @@ -138,20 +141,27 @@ COPY --chown=${USERNAME}:ton --chmod=775 entrypoint.sh ${APP_HOME}

RUN chmod =2775 ${PIPELINE_ROOT} \
&& chmod =2775 ${APP_HOME} \
&& mv de440.bsp ${PIPELINE_PATH}/de440.bsp \
&& mv naif0012.tls ${PIPELINE_PATH}/naif0012.tls
&& mv de440.bsp ${PIPELINE_PATH}/$BSP_PLANETARY_NAME \
&& mv naif0012.tls ${PIPELINE_PATH}/$LEAP_SECOND_NAME

WORKDIR ${APP_HOME}

USER apptno
# RUN /bin/bash --login -c "conda init bash \
# && echo 'conda activate py3' >> ~/.bashrc \
# && source ~/.bashrc"
RUN /bin/bash --login -c "conda init bash \
&& echo 'conda activate py3' >> ~/.bashrc \
&& echo 'source /app/src/env.sh' >> ~/.bashrc \
&& source ~/.bashrc"
ENV PATH=${PATH}:/home/apptno/.local/bin

# USER ${USERNAME}
# RUN /bin/bash --login -c "conda init bash \
# && echo 'conda activate py3' >> ~/.bashrc \
# && source ~/.bashrc"
USER ${USERNAME}
RUN /bin/bash --login -c "conda init bash \
&& echo 'conda activate py3' >> ~/.bashrc \
&& echo 'source /app/src/env.sh' >> ~/.bashrc \
&& source ~/.bashrc"
ENV PATH=${PATH}:/home/${USERNAME}/.local/bin

Expand Down
31 changes: 31 additions & 0 deletions predict_occultation/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,35 @@
echo "Running Rsync: ${PIPELINE_PREDIC_OCC}"
rsync -r /app/src/predict_occultation/ ${PIPELINE_PREDIC_OCC}/


# Baixa os arquivos bsp planetary e leap_second caso não existam.
# No build da imagem eles são baixados, mas para os devs,
# Na primeira execução eles serão sobrescritos por isso
# Essa checagem adicional.
bsp_planetary="${PIPELINE_PATH}/$BSP_PLANETARY_NAME"
if [ ! -f $bsp_planetary ];
then
echo "BSP Planetary $BSP_PLANETARY_NAME does not exist in the pipeline path.";
echo "Downloading $BSP_PLANETARY_NAME.";
wget --no-verbose --show-progress \
--progress=bar:force:noscroll \
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/$BSP_PLANETARY_NAME \
-O $bsp_planetary
echo "BSP Planetary Downloaded to: $bsp_planetary"
fi

leap_second="${PIPELINE_PATH}/$LEAP_SECOND_NAME"
if [ ! -f $leap_second ];
then
echo "Leap Second $LEAP_SECOND_NAME does not exist in the pipeline path.";
echo "Downloading $LEAP_SECOND_NAME.";
wget --no-verbose --show-progress \
--progress=bar:force:noscroll \
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/$LEAP_SECOND_NAME \
-O $leap_second
echo "Leap Second Downloaded to: $leap_second"
fi

echo "Enviroment ${PARSL_ENV} is ready!"

exec "$@"
1 change: 1 addition & 0 deletions predict_occultation/src/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
echo "Activating py3 environment"
conda activate py3

echo "Setup PYTHONPATH"
export PYTHONPATH=${PYTHONPATH}:${PIPELINE_ROOT}:${PIPELINE_PREDIC_OCC}:${PIPELINE_PATH}

if [[ "$PARSL_ENV" = "linea" ]]
Expand Down
2 changes: 1 addition & 1 deletion predict_occultation/src/rerun.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash --login

set -o errexit
set -o pipefail
Expand Down

0 comments on commit d1a895c

Please sign in to comment.