Skip to content

Commit 867aa1c

Browse files
committed
Update permission management, add helper and change default port to 8080
1 parent 0c97c7b commit 867aa1c

7 files changed

+48
-45
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.env
22
.vscode
33
.DS_store
4+
.codebuddy
5+
.idea

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ COPY start.sh /start.sh
9797
RUN chmod +x /start.sh
9898

9999
# Install Leantime
100-
ARG LEAN_VERSION=3.4.0
100+
ARG LEAN_VERSION=3.4.1
101101
RUN set -ex; \
102102
curl -fsSL --retry 3 https://github.com/Leantime/leantime/releases/download/v${LEAN_VERSION}/Leantime-v${LEAN_VERSION}.tar.gz -o leantime.tar.gz && \
103103
tar xzf leantime.tar.gz --strip-components 1 && \
@@ -107,5 +107,5 @@ RUN set -ex; \
107107
# Switch to non-root user
108108
USER www-data
109109

110-
EXPOSE 80
110+
EXPOSE 8080
111111
ENTRYPOINT ["/sbin/tini", "--", "/start.sh"]

README.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ This is the official <a href="https://hub.docker.com/r/leantime/leantime">Docker
1717
## How to use this image
1818
Below you will find examples on how to get started with Leantime trough `docker run` or `docker compose`.
1919

20-
21-
2220
### Option 1: Quick Start with Docker Compose (Recommended)
2321

2422
```
@@ -52,6 +50,21 @@ docker network create leantime-net
5250

5351
## Docker specific configuration options
5452

53+
### Port Configuration
54+
By default, Leantime runs on port 8080 internally. If you need to use port 80, you have two options:
55+
56+
1. Map port 80 externally to 8080 internally in docker-compose.yml:
57+
58+
```
59+
ports: - "80:8080"
60+
```
61+
62+
2. Add required capabilities (not recommended):
63+
64+
```
65+
cap_add: - CAP_NET_BIND_SERVICE
66+
```
67+
5568
### Running as Non-Root User
5669
Add the `user` directive to your docker-compose.yml:
5770

config/nginx.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ http {
3434
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
3535

3636
server {
37-
listen 80;
37+
listen 8080;
3838
server_name _;
3939
root /var/www/html/public;
4040
index index.php;

docker-compose.yml

+21-2
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,38 @@ services:
2222
#user: "www-data" # Run as non-root user
2323
restart: unless-stopped
2424
env_file: ./.env # Environment file with settings
25+
# Add security options
26+
security_opt:
27+
- no-new-privileges:true
28+
# Add capabilities
29+
cap_add:
30+
- CAP_NET_BIND_SERVICE
31+
- CAP_CHOWN
32+
- CAP_SETGID
33+
- CAP_SETUID
34+
ports:
35+
- "${LEAN_PORT:-8080}:8080"
2536
networks:
2637
- leantime-net
2738
volumes:
2839
- public_userfiles:/var/www/html/public/userfiles # Volume to store public files, logo etc
2940
- userfiles:/var/www/html/userfiles # Original volume name for compatibility
3041
- plugins:/var/www/html/app/Plugins # Plugin storage
3142
- logs:/var/www/html/storage/logs # Log storage
32-
ports:
33-
- "${LEAN_PORT}:80" # The port to expose and access Leantime
3443
depends_on:
3544
leantime_db:
3645
condition: service_healthy
3746

47+
# Add a helper container for volume permissions
48+
# Run via docker compose --profile mysql_helper up -d
49+
mysql_helper:
50+
image: mysql:8.4
51+
command: chown -R mysql:mysql /var/lib/mysql
52+
volumes:
53+
- db_data:/var/lib/mysql
54+
user: root
55+
profiles: [ "helper" ]
56+
3857
volumes:
3958
db_data:
4059
userfiles: # New volume for public files

sample.env

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
# If you don't want to maintain a file like this you can pass in all variables via Server Variables
33

44
## Minimum Configuration, these are required for installation
5+
PUID=1000
6+
PGID=1000
57

6-
LEAN_PORT = '8081' # The port to expose and access Leantime
8+
LEAN_PORT = '8080' # The port to expose and access Leantime
79
LEAN_APP_URL = '' # Base URL, needed for subfolder or proxy installs (including http:// or https://)
810
LEAN_APP_DIR = '' # Base of application without trailing slash (used for cookies), e.g, /leantime
911

@@ -16,7 +18,7 @@ MYSQL_USER = 'lean' # Database username
1618
MYSQL_PASSWORD = 'changeme123' # Database password
1719

1820
# Database - leantime container
19-
LEAN_DB_HOST = 'mysql_leantime' # Database host
21+
LEAN_DB_HOST = 'mysql_leantime' # Database host
2022
LEAN_DB_USER = 'lean' # Database username (needs to be the same as MYSQL_USER)
2123
LEAN_DB_PASSWORD = 'changeme123' # Database password (needs to be the same as MYSQL_PASSWORD)
2224
LEAN_DB_DATABASE = 'leantime' # Database name (needs to be the same as MYSQL_DATABASE)

start.sh

+3-36
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,5 @@
11
#!/bin/sh
22

3-
# Function to set permissions
4-
set_permissions() {
5-
# Only set permissions if running as root
6-
if [ "$(id -u)" = "0" ]; then
7-
chown -R www-data:www-data /var/www/html
8-
chmod -R 775 /var/www/html
9-
10-
# Ensure specific directories exist and have correct permissions
11-
local dirs="/var/www/html/userfiles /var/www/html/public/userfiles /var/www/html/storage/logs /var/www/html/app/Plugins"
12-
for dir in $dirs; do
13-
mkdir -p "$dir"
14-
chown -R www-data:www-data "$dir"
15-
chmod 2775 "$dir"
16-
done
17-
18-
# Ensure supervisord can write its pid file
19-
mkdir -p /run && chown www-data:www-data /run
20-
fi
21-
}
22-
23-
# Handle PUID/PGID
24-
if [ -n "${PUID}" ] && [ -n "${PGID}" ]; then
25-
if [ -n "${PUID}" ] && [ "${PUID}" != "1000" ]; then
26-
usermod -u "${PUID}" www-data
27-
fi
28-
if [ -n "${PGID}" ] && [ "${PGID}" != "1000" ]; then
29-
groupmod -g "${PGID}" www-data
30-
fi
31-
32-
# After changing UID/GID, we need to fix permissions
33-
set_permissions
34-
fi
35-
36-
# Always ensure correct permissions
37-
set_permissions
38-
393
if [[ -n "${LEAN_DB_PASSWORD_FILE}" ]]; then
404
LEAN_DB_PASSWORD=$(cat "${LEAN_DB_PASSWORD_FILE}")
415
export LEAN_DB_PASSWORD
@@ -81,4 +45,7 @@ if [[ -n "${LEAN_EMAIL_SMTP_USERNAME_FILE}" ]]; then
8145
export LEAN_EMAIL_SMTP_USERNAME
8246
fi
8347

48+
# Ensure supervisord can write its pid file
49+
mkdir -p /run
50+
8451
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf

0 commit comments

Comments
 (0)