Skip to content

Commit a6b9a50

Browse files
authored
Merge pull request #66 from abordage/feature/workspace-terminal-width-limit
feat(workspace): add terminal width configuration support
2 parents 80400ce + 86b0eb9 commit a6b9a50

File tree

6 files changed

+73
-6
lines changed

6 files changed

+73
-6
lines changed

.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ ENABLE_SERVICES="nginx php-fpm workspace postgres mysql redis rabbitmq elasticse
3030
#
3131
DEPENDENCY_PHP_EXTENSIONS="amqp apcu ast bcmath bz2 decimal exif gd gmp imagick intl pcov pcntl pdo_mysql pdo_pgsql pgsql redis soap sockets xdebug xlswriter xsl yaml zip"
3232

33+
# =============================================================================
34+
# Build Configuration
35+
# =============================================================================
36+
# Debian mirror for faster package downloads (leave empty for default)
37+
# Examples: http://ftp.lt.debian.org/debian, http://ftp.no.debian.org/debian
38+
DEBIAN_MIRROR=
39+
3340
# =============================================================================
3441
# Port Configuration
3542
# =============================================================================
@@ -91,6 +98,9 @@ HEALTH_CHECK_RETRIES=3
9198
# =============================================================================
9299
NODE_VERSION=22
93100

101+
# Terminal width limit in columns (default: 120, set to 0 to disable)
102+
TERMINAL_MAX_COLUMNS=120
103+
94104
# =============================================================================
95105
# NGINX Configuration
96106
# =============================================================================

Makefile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,23 @@ restart: ## Restart selected services with network aliases
8989
@$(call show_aliases_status)
9090
@$(DOCKER_COMPOSE) $(COMPOSE_FILES) restart $(shell echo $(ENABLE_SERVICES))
9191

92-
rebuild: ## [DEPRECATED] Use 'make update' instead
93-
@echo "$(YELLOW)Please use 'make update' instead$(NC)"
94-
@echo ""
95-
@$(MAKE) update
92+
rebuild: ## Rebuild workspace and php-fpm images and restart services
93+
@echo "$(BLUE)Rebuilding workspace and php-fpm images...$(NC)"
94+
@echo "$(YELLOW)Step 1: Stopping containers...$(NC)"
95+
@$(DOCKER_COMPOSE) $(COMPOSE_FILES) stop workspace php-fpm
96+
@echo "$(YELLOW)Step 2: Removing containers...$(NC)"
97+
@$(DOCKER_COMPOSE) $(COMPOSE_FILES) rm -f workspace php-fpm
98+
@echo "$(YELLOW)Step 3: Removing existing images...$(NC)"
99+
@PROJECT_NAME=$$(grep '^PROJECT_NAME=' $(ENV_FILE) | cut -d'=' -f2) && \
100+
PROJECT_SUFFIX=$$(grep '^PROJECT_SUFFIX=' $(ENV_FILE) | cut -d'=' -f2) && \
101+
COMPOSE_PROJECT_NAME="$$PROJECT_NAME-$$PROJECT_SUFFIX" && \
102+
docker rmi "$$COMPOSE_PROJECT_NAME-workspace:latest" 2>/dev/null || echo "$(GREEN)No workspace image to remove$(NC)" && \
103+
docker rmi "$$COMPOSE_PROJECT_NAME-php-fpm:latest" 2>/dev/null || echo "$(GREEN)No php-fpm image to remove$(NC)"
104+
@echo "$(YELLOW)Step 4: Building images with no cache...$(NC)"
105+
@$(DOCKER_COMPOSE) $(COMPOSE_FILES) build --no-cache workspace php-fpm
106+
@echo "$(YELLOW)Step 5: Starting services...$(NC)"
107+
@$(MAKE) start
108+
@echo "$(GREEN)✓ Rebuild completed successfully!$(NC)"
96109

97110
update: ## Update DockerKit, reinstall dk command, and rebuild containers (with cache)
98111
@tools/update.sh

docker-compose.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ services:
1717
- NODE_VERSION
1818
# PostgreSQL
1919
- POSTGRES_VERSION
20+
# Build configuration
21+
- DEBIAN_MIRROR
2022
restart: on-failure:3
2123
depends_on:
2224
postgres:
@@ -34,6 +36,8 @@ services:
3436
environment:
3537
- CHOKIDAR_USEPOLLING=true
3638
- TZ
39+
# Terminal configuration
40+
- TERMINAL_MAX_COLUMNS
3741
# Container user configuration
3842
- APP_USER
3943
- APP_UID
@@ -91,6 +95,8 @@ services:
9195
- APP_GID
9296
# PHP Extensions
9397
- DEPENDENCY_PHP_EXTENSIONS
98+
# Build configuration
99+
- DEBIAN_MIRROR
94100
restart: on-failure:3
95101
extra_hosts:
96102
- "host.docker.internal:host-gateway"
@@ -291,6 +297,7 @@ services:
291297

292298
# Development optimizations
293299
- action.auto_create_index=true
300+
- action.destructive_requires_name=false
294301
- bootstrap.memory_lock=false
295302
- cluster.routing.allocation.disk.threshold_enabled=false
296303
- cluster.routing.allocation.node_concurrent_recoveries=2

php-fpm/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ ARG DEPENDENCY_PHP_EXTENSIONS
1313
# cURL Configuration
1414
ARG CURL_VERSION=curl-8_16_0
1515

16+
# Debian Mirror Configuration
17+
ARG DEBIAN_MIRROR=
18+
1619
FROM php:${PHP_VERSION}-fpm AS base
1720

1821
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -58,11 +61,23 @@ RUN groupadd -g "${APP_GID}" "${APP_USER}" && \
5861
# ============================================================================
5962
FROM base AS dependencies
6063

64+
ARG DEBIAN_MIRROR=
65+
6166
USER root
67+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
6268

6369
# Install minimal system tools for PHP-FPM operation
6470
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
6571
--mount=type=cache,target=/var/lib/apt,sharing=locked \
72+
set -eux; \
73+
# Configure Debian mirror \
74+
MIRROR="${DEBIAN_MIRROR:-http://deb.debian.org/debian}" && \
75+
if [ "${MIRROR}" != "http://deb.debian.org/debian" ]; then \
76+
echo "Configuring Debian mirror: ${MIRROR}"; \
77+
[ -f /etc/apt/sources.list.d/debian.sources ] && sed -i "s|http://deb.debian.org/debian|${MIRROR}|g" /etc/apt/sources.list.d/debian.sources; \
78+
[ -f /etc/apt/sources.list ] && sed -i "s|http://deb.debian.org/debian|${MIRROR}|g" /etc/apt/sources.list; \
79+
echo "Debian mirror configured successfully"; \
80+
fi && \
6681
apt-get update && \
6782
apt-get install -y --no-install-recommends \
6883
build-essential \

workspace/Dockerfile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ ARG CURL_VERSION=curl-8_16_0
2222
# Xdebug Configuration
2323
ARG PHP_XDEBUG_CLIENT_PORT=9003
2424

25+
# Debian Mirror Configuration
26+
ARG DEBIAN_MIRROR=
27+
2528
FROM php:${PHP_VERSION}-cli AS base
2629

2730
# Import ARG values into this stage
@@ -59,6 +62,7 @@ RUN groupadd -g "${APP_GID}" "${APP_USER}" && \
5962
FROM base AS dependencies
6063

6164
ARG POSTGRES_VERSION=17
65+
ARG DEBIAN_MIRROR=
6266

6367
USER root
6468
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
@@ -67,6 +71,14 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
6771
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
6872
--mount=type=cache,target=/var/lib/apt,sharing=locked \
6973
set -eux; \
74+
# Configure Debian mirror \
75+
MIRROR="${DEBIAN_MIRROR:-http://deb.debian.org/debian}" && \
76+
if [ "${MIRROR}" != "http://deb.debian.org/debian" ]; then \
77+
echo "Configuring Debian mirror: ${MIRROR}"; \
78+
[ -f /etc/apt/sources.list.d/debian.sources ] && sed -i "s|http://deb.debian.org/debian|${MIRROR}|g" /etc/apt/sources.list.d/debian.sources; \
79+
[ -f /etc/apt/sources.list ] && sed -i "s|http://deb.debian.org/debian|${MIRROR}|g" /etc/apt/sources.list; \
80+
echo "Debian mirror configured successfully"; \
81+
fi && \
7082
apt-get update && \
7183
apt-get install -y --no-install-recommends \
7284
bash-completion \
@@ -106,7 +118,8 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
106118
--mount=type=cache,target=/var/lib/apt,sharing=locked \
107119
set -eux; \
108120
# Add Debian Backports repository \
109-
echo "deb http://deb.debian.org/debian bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \
121+
MIRROR="${DEBIAN_MIRROR:-http://deb.debian.org/debian}" && \
122+
echo "deb ${MIRROR} bookworm-backports main" > /etc/apt/sources.list.d/backports.list && \
110123
apt-get update && \
111124
# Install latest versions from backports \
112125
apt-get install -y --no-install-recommends -t bookworm-backports \

workspace/shell/.bashrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ shopt -s checkwinsize
2121
# Save history immediately after each command (prevents loss on container restart)
2222
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a"
2323

24+
# Terminal width configuration
25+
TERMINAL_MAX_COLUMNS=${TERMINAL_MAX_COLUMNS:-120}
26+
27+
# Cap terminal width before each command for better output formatting
28+
_cap_columns() {
29+
[[ $COLUMNS -gt $TERMINAL_MAX_COLUMNS ]] && export COLUMNS=$TERMINAL_MAX_COLUMNS
30+
}
31+
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}_cap_columns"
32+
2433
# Enable bash completion
2534
if ! shopt -oq posix; then
2635
if [ -f /usr/share/bash-completion/bash_completion ]; then
@@ -62,7 +71,7 @@ fi
6271
if [[ $- == *i* ]] && [[ -t 1 ]] && command -v resize >/dev/null 2>&1; then
6372
# Initial resize on shell start
6473
eval "$(resize 2>/dev/null)"
65-
74+
6675
# Auto-update on terminal window resize
6776
trap 'eval "$(resize 2>/dev/null)"' WINCH
6877
fi

0 commit comments

Comments
 (0)