Skip to content

Commit

Permalink
feat(docker): add support for restart policy and TTY options
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia committed Oct 15, 2024
1 parent 1347c1e commit 3d41a1f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .copier-docker-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; do NOT edit manually
_commit: v0.30.6-10-g90bb37e
_commit: v0.31.5-2-g927d89e
_src_path: .
app_dirname: entelecheia
app_install_root: /opt
Expand Down Expand Up @@ -67,6 +67,7 @@ project_short_description: Hyperfast Docker Template is a powerful tool that lev
copier to streamline the creation of new Docker projects. It simplifies and accelerates
Docker configurations, fostering a highly efficient and user-friendly development
experience.
restart_always: true
ssh_host_port: 2929
ssh_port: 22
use_deploy_workflows: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ services:
image: $IMAGE_NAME:$IMAGE_TAG
# Sets the hostname of the container
hostname: $CONTAINER_HOSTNAME
{% if restart_always %}restart: always{% endif %}
# Sets tty to true if the container needs a pseudo-TTY
tty: `{{ use_tty | lower }}`
{% if use_tty %}stdin_open: true{% endif %}
{% if use_tty %}# {% endif %}command:
{% if use_tty %}# {% endif %} # Specifies the command to be executed when the container is run
{% if use_tty %}# {% endif %} - bash
Expand Down
2 changes: 2 additions & 0 deletions .docker/docker-compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ services:
image: $IMAGE_NAME:$IMAGE_TAG
# Sets the hostname of the container
hostname: $CONTAINER_HOSTNAME
restart: always
# Sets tty to true if the container needs a pseudo-TTY
tty: false

command:
# Specifies the command to be executed when the container is run
- bash
Expand Down
5 changes: 5 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ use_tty:
type: bool
help: Do you want to enable tty (pseudo-terminal) when running the Docker container?

restart_always:
default: false
type: bool
help: Do you want to set restart policy to 'always' for the Docker container?

use_ssh_service:
default: true
type: bool
Expand Down
3 changes: 2 additions & 1 deletion tmp/.copier-docker-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; do NOT edit manually
_commit: v0.30.6-4-gd74e456
_commit: v0.31.5-2-g7796203
_src_path: .
app_dirname: entelecheia
app_install_root: /workspace/projects
Expand Down Expand Up @@ -67,6 +67,7 @@ project_short_description: Hyperfast Docker Template is a powerful tool that lev
copier to streamline the creation of new Docker projects. It simplifies and accelerates
Docker configurations, fostering a highly efficient and user-friendly development
experience.
restart_always: false
ssh_host_port: 2222
ssh_port: 22
use_deploy_workflows: true
Expand Down
2 changes: 2 additions & 0 deletions tmp/.docker/docker-compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ services:
image: $IMAGE_NAME:$IMAGE_TAG
# Sets the hostname of the container
hostname: $CONTAINER_HOSTNAME

# Sets tty to true if the container needs a pseudo-TTY
tty: false

command:
# Specifies the command to be executed when the container is run
- bash
Expand Down
2 changes: 1 addition & 1 deletion tmp/.docker/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if [ "$USER_UID" != "$LOCAL_UID" ]; then
echo "Changing ownership of $APP_INSTALL_ROOT directory to $USER_UID:$USER_UID"
chown -R "$USER_UID:$USER_UID" "$APP_INSTALL_ROOT"
fi
if [ -n "$WORKSPACE_ROOT" ] && [ -d "$WORKSPACE_ROOT" ]; then
if [ -n "$WORKSPACE_ROOT" ] && [ -d "$WORKSPACE_ROOT" ] && [ "$WORKSPACE_ROOT" != "$APP_INSTALL_ROOT" ]; then
echo "Changing ownership of workspace directory [$WORKSPACE_ROOT] to $USER_UID:$USER_UID"
chown -R "$USER_UID:$USER_UID" "$WORKSPACE_ROOT"
fi
Expand Down
19 changes: 10 additions & 9 deletions tmp/.docker/scripts/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ service ssh start
# set token to value of JUPYTER_TOKEN
# set port to value of JUPYTER_DOCKER_PORT
if [[ -z "$(command -v jupyter)" ]]; then
echo "Jupyter not installed. Exiting..."
exit 1
echo "Jupyter not installed."
else
echo "Starting Jupyter Lab..."
jupyter lab \
--no-browser \
--notebook-dir="$WORKSPACE_ROOT" \
--ServerApp.token="$JUPYTER_TOKEN" \
--port="$JUPYTER_PORT" \
--ip=0.0.0.0 \
--allow-root
fi
exec gosu "${USER}" jupyter lab \
--no-browser \
--notebook-dir="$WORKSPACE_ROOT" \
--ServerApp.token="$JUPYTER_TOKEN" \
--port="$JUPYTER_PORT" \
--ip=0.0.0.0 \
--allow-root

0 comments on commit 3d41a1f

Please sign in to comment.