Skip to content

Commit

Permalink
Add another Docker volume for general file storage
Browse files Browse the repository at this point in the history
  • Loading branch information
martinburchell committed May 11, 2023
1 parent 33d4c66 commit 25b90b1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docker/dockerfiles/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# Those without defaults:
#
# CRATE_DOCKER_CONFIG_HOST_DIR
# CRATE_DOCKER_FILES_HOST_DIR
# CRATE_DOCKER_GATE_BIOYODIE_RESOURCES_HOST_DIR
# CRATE_DOCKER_MYSQL_CRATE_USER_PASSWORD
# CRATE_DOCKER_MYSQL_CRATE_ROOT_PASSWORD
Expand Down Expand Up @@ -74,6 +75,16 @@ volumes:
# https://docs.docker.com/compose/compose-file/#variable-substitution
device: "${CRATE_DOCKER_CONFIG_HOST_DIR}"

crate_files_volume:
# General file storage on the host machine
driver: local
driver_opts:
o: bind
type: none
# We use environment variable substitution.
# https://docs.docker.com/compose/compose-file/#variable-substitution
device: "${CRATE_DOCKER_FILES_HOST_DIR}"

crate_static_volume:
# Space to collect static files (Django STATIC_ROOT)
driver: local
Expand Down Expand Up @@ -372,6 +383,7 @@ services:
volumes:
- bioyodie_resource_volume:/crate/bioyodie/bio-yodie-resources
- crate_config_volume:/crate/cfg
- crate_files_volume:/crate/files
- crate_static_volume:/crate/static
- crate_tmp_volume:/crate/tmp

Expand Down Expand Up @@ -437,6 +449,7 @@ services:
volumes:
- bioyodie_resource_volume:/crate/bioyodie/bio-yodie-resources
- crate_config_volume:/crate/cfg
- crate_files_volume:/crate/files
- crate_static_volume:/crate/static
- crate_tmp_volume:/crate/tmp

Expand Down
1 change: 1 addition & 0 deletions github_action_scripts/set_crate_docker_environment
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export CRATE_DOCKER_CRATEWEB_SUPERUSER_EMAIL=admin@example.com
export CRATE_DOCKER_CRATEWEB_SUPERUSER_PASSWORD=servisolironcamera
export CRATE_DOCKER_CRATEWEB_SUPERUSER_USERNAME=admin
export CRATE_DOCKER_CRATEWEB_USE_HTTPS=0
export CRATE_DOCKER_FILES_HOST_DIR=${HOME}/crate_files
export CRATE_DOCKER_GATE_BIOYODIE_RESOURCES_HOST_DIR=${HOME}/bioyodie_resources
export CRATE_DOCKER_INSTALL_USER_ID=$(id -u)
export CRATE_DOCKER_MYSQL_CRATE_HOST_PORT=3307
Expand Down
15 changes: 15 additions & 0 deletions installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class DockerEnvVar:
)
CRATEWEB_SUPERUSER_USERNAME = f"{PREFIX}_CRATEWEB_SUPERUSER_USERNAME"
CRATEWEB_USE_HTTPS = f"{PREFIX}_CRATEWEB_USE_HTTPS"
FILES_HOST_DIR = f"{PREFIX}_FILES_HOST_DIR"
GATE_BIOYODIE_RESOURCES_HOST_DIR = (
f"{PREFIX}_GATE_BIOYODIE_RESOURCES_HOST_DIR"
)
Expand Down Expand Up @@ -474,6 +475,11 @@ def configure_config_files(self) -> None:
self.setenv(DockerEnvVar.CRATE_ANON_CONFIG, "crate_anon_config.ini")
self.setenv(DockerEnvVar.ODBC_USER_CONFIG, "odbc_user.ini")

def configure_files_dir(self) -> None:
self.setenv(
DockerEnvVar.FILES_HOST_DIR, self.get_docker_files_host_dir
)

def configure_static_dir(self) -> None:
self.setenv(
DockerEnvVar.STATIC_HOST_DIR, self.get_docker_static_host_dir
Expand Down Expand Up @@ -580,6 +586,9 @@ def create_directories() -> None:
crate_config_dir = os.environ.get(DockerEnvVar.CONFIG_HOST_DIR)
Path(crate_config_dir).mkdir(parents=True, exist_ok=True)

crate_files_dir = os.environ.get(DockerEnvVar.FILES_HOST_DIR)
Path(crate_files_dir).mkdir(parents=True, exist_ok=True)

crate_static_dir = os.environ.get(DockerEnvVar.STATIC_HOST_DIR)
Path(crate_static_dir).mkdir(parents=True, exist_ok=True)

Expand Down Expand Up @@ -907,6 +916,12 @@ def get_docker_config_host_dir(self) -> str:
default=HostPath.DEFAULT_HOST_CRATE_CONFIG_DIR,
)

def get_docker_files_host_dir(self) -> str:
return self.get_user_dir(
"Select the host directory for general CRATE file storage",
default=HostPath.DEFAULT_HOST_CRATE_FILES_DIR,
)

def get_docker_static_host_dir(self) -> str:
return self.get_user_dir(
"Select the host directory where CRATE will store static files "
Expand Down

0 comments on commit 25b90b1

Please sign in to comment.