File size: 1,383 Bytes
8c486a8
 
 
 
 
 
3d5d7e9
 
 
 
 
8c486a8
 
 
 
 
 
 
 
 
 
 
7fedc25
 
8c486a8
 
 
 
 
3d5d7e9
 
8c486a8
 
 
 
7fedc25
 
8c486a8
 
 
 
 
 
 
 
3d5d7e9
8c486a8
 
3d5d7e9
8c486a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends \
    nginx \
    php8.1-fpm \
    php8.1-mysql \
    php8.1-ldap \
    php8.1-xml \
    php8.1-mbstring \
    openssh-server \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Configure SSH
RUN mkdir /var/run/sshd && \
    echo 'PermitRootLogin no' >> /etc/ssh/sshd_config && \
    echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config

# Create app users
{% for user in users %}
RUN useradd -m -s /bin/bash {{ user.username | shell_quote }} && \
    echo {{ (user.username ~ ':' ~ user.password) | shell_quote }} | chpasswd
{% endfor %}

# Copy nginx config
COPY nginx.conf /etc/nginx/sites-available/default

# Set up web root
RUN mkdir -p /var/www/portal/admin /var/www/portal/api /var/www/portal/reports

# Create flag files (if any are on this host)
{% for flag in flags %}
{% if flag.host == 'web' and '/' in flag.path %}
RUN mkdir -p $(dirname {{ flag.path | shell_quote }}) && \
    echo {{ flag.value | shell_quote }} > {{ flag.path | shell_quote }}
{% endif %}
{% endfor %}

# Logging
RUN mkdir -p /var/log/app && \
    ln -sf /var/log/app/access.log /var/log/nginx/access.log && \
    ln -sf /var/log/app/error.log /var/log/nginx/error.log

EXPOSE 80 443 22

CMD service ssh start && \
    service php8.1-fpm start && \
    nginx -g 'daemon off;'