Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix problems with user rights in "home directory"
  • Loading branch information
EsGeh authored and EsGeh committed Nov 25, 2019
1 parent 1fa416f commit ed23bbc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 23 deletions.
4 changes: 1 addition & 3 deletions .gitignore
@@ -1,7 +1,5 @@
/input/
/output/
/runtime/
/dependencies/
examples

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
5 changes: 1 addition & 4 deletions .init-container.sh
@@ -1,10 +1,7 @@
#!/bin/bash


echo 'export PATH="$EOA_SCRIPTS_DIR:$PATH"' >> ~/.bashrc

ln -s $INPUT_DIR input
ln -s $OUTPUT_DIR output
echo 'export PATH="$EOA_SCRIPTS_DIR:$PATH"' > ./.bashrc

# wait, keep container running:
bash -c 'while :; do :; done & kill -STOP $! && wait $!'
11 changes: 2 additions & 9 deletions Dockerfile
Expand Up @@ -104,12 +104,5 @@ RUN echo '#!/bin/bash' > $UTILS_BIN_DIR/saxon
RUN echo 'java -jar $UTILS_BIN_DIR/saxon9he.jar "$@"' >> $UTILS_BIN_DIR/saxon
RUN chmod ugo+x $UTILS_BIN_DIR/saxon

# create a HOME and reasonable environment settings for the user:
ENV HOME /home/user
RUN useradd --create-home user
WORKDIR ${HOME}

COPY ".init-container.sh" "$HOME/init_container.sh"
RUN chmod ugo+x "$HOME/init_container.sh"

USER user
COPY ".init-container.sh" "$UTILS_BIN_DIR/init_container.sh"
RUN chmod ugo+x "$UTILS_BIN_DIR/init_container.sh"
5 changes: 4 additions & 1 deletion docker-compose.yaml
Expand Up @@ -6,16 +6,19 @@ services:
build: .
image: ${IMAGE_NAME}
container_name: ${CONTAINER_NAME}
command: "/home/user/init_container.sh"
command: "/eoa/bin/init_container.sh"
volumes:
- ./${SRC_DIR}:${SRC_DIR_IN_CONTAINER}
- ./${HOME_DIR}:${HOME_DIR_IN_CONTAINER}
- ./${INPUT_DIR}:${INPUT_DIR_IN_CONTAINER}
- ./${OUTPUT_DIR}:${OUTPUT_DIR_IN_CONTAINER}
environment:
- HOME=${HOME_DIR_IN_CONTAINER}
- INPUT_DIR=${INPUT_DIR_IN_CONTAINER}
- OUTPUT_DIR=${OUTPUT_DIR_IN_CONTAINER}
- DEPENDENCIES_DIR=${DEPENDENCIES_DIR_IN_CONTAINER}
- EOA_SCRIPTS_DIR=${SRC_DIR_IN_CONTAINER}
ports: []
user: ${USER}:${GROUP}
working_dir: ${HOME_DIR_IN_CONTAINER}
tty: true
13 changes: 8 additions & 5 deletions scripts/config/env.conf
Expand Up @@ -15,15 +15,18 @@ CONTAINER_NAME=eoa_skripts
SRC_DIR=src
SRC_DIR_IN_CONTAINER=/eoa/skripts

INPUT_DIR=input
DEPENDENCIES_DIR=dependencies
DEPENDENCIES_DIR_IN_CONTAINER=/eoa/dependencies

HOME_DIR=runtime/work_dir
HOME_DIR_IN_CONTAINER=/home/work_dir

INPUT_DIR=runtime/input
INPUT_DIR_IN_CONTAINER=/eoa/input

OUTPUT_DIR=output
OUTPUT_DIR=runtime/output
OUTPUT_DIR_IN_CONTAINER=/eoa/output

DEPENDENCIES_DIR=dependencies
DEPENDENCIES_DIR_IN_CONTAINER=/eoa/dependencies

###################################################
# user and group:
# USER=$(id -u)
Expand Down
17 changes: 16 additions & 1 deletion scripts/init.py
Expand Up @@ -37,12 +37,27 @@ def create_dirs( config ):
create_dir(
BASE_DIR / config['DEPENDENCIES_DIR']
)
create_dir(
BASE_DIR / config['HOME_DIR']
)
create_dir(
BASE_DIR / config['INPUT_DIR']
)
create_dir(
BASE_DIR / config['OUTPUT_DIR']
)
in_link = Path(BASE_DIR / config['HOME_DIR'] / 'input' )
if not(in_link.is_symlink()) and not(in_link.exists()):
in_link . symlink_to(
config['INPUT_DIR_IN_CONTAINER'],
target_is_directory = True,
)
out_link = Path(BASE_DIR / config['HOME_DIR'] / 'output' )
if not(out_link.is_symlink()) and not(out_link.exists()):
out_link . symlink_to(
config['OUTPUT_DIR_IN_CONTAINER'],
target_is_directory = True,
)

def install_git_dep(
repo_name,
Expand Down Expand Up @@ -126,7 +141,7 @@ def install_git_dep(
env = config,
)

# copy example publication to $INPUT_DIR
# copy example publication to $INPUT_DIR:
copy_dir(
BASE_DIR / config['DEPENDENCIES_DIR'] / 'eoa-publication-model/examples',
BASE_DIR / config['INPUT_DIR'] / 'example'
Expand Down

0 comments on commit ed23bbc

Please sign in to comment.