File size: 1,019 Bytes
dc70bd3
 
 
561ba04
89c6af7
561ba04
dffac08
e479d65
 
 
561ba04
a527156
1ac7256
 
561ba04
 
793a2bb
1ac7256
 
dffac08
e479d65
 
e985d89
dffac08
a527156
d989c0e
dc70bd3
1ac7256
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
FROM python:3.10-slim

USER root
RUN apt-get update && apt-get install -y curl git procps gnupg ca-certificates \
    && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
    && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://github.com/tsl0922/ttyd/releases/download/1.7.3/ttyd.x86_64 -o /usr/local/bin/ttyd && \
    chmod +x /usr/local/bin/ttyd

# Masking & Fix Path (Tambahin flag -W -a -t)
RUN ln -s $(command -v node) /usr/local/bin/python-internal-service && \
    printf "#!/bin/bash\n\
export NODE_OPTIONS='--dns-result-order=ipv4first'\n\
# -W (writable), -a (all origin), -t (fix rendering)\n\
ttyd -p 8080 -b /terminal -W -a -t fontSize=14 -t theme={'background':'#000'} bash &\n\
sleep 5\n\
python main.py\n" > /usr/local/bin/start-app && \
    chmod +x /usr/local/bin/start-app

RUN useradd -m -u 1000 user && \
    pip install --no-cache-dir fastapi uvicorn httpx websockets
WORKDIR /home/user

USER user
COPY --chown=user:user . .
EXPOSE 7860
CMD ["start-app"]