Skip to content

Commit

Permalink
Docker: No longer building the app in runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisCris committed Apr 28, 2024
1 parent 0a6b43f commit a04a6e0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 71 deletions.
4 changes: 4 additions & 0 deletions docker/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.git
.github
.vscode
save_data_re
tests
venv/
logs/
gamesave*/
Expand Down
50 changes: 12 additions & 38 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,52 +1,26 @@
# Use an official Python runtime as a parent image
# FROM python:3.11-slim
FROM nikolaik/python-nodejs:python3.12-nodejs21-slim

# Define environment variables for customization
# ENV TZ=UTC \
# PUID=1000 \
# PGID=1000 \
# APP_PORT=8000 \
# APP_LANG=en \
# LANG=C.UTF-8 \
# PYTHONUNBUFFERED=1 \
# MODE=--cli \
# SAVE_PATH="/mnt/gamesave" \
# PASSWORD=null

# Set the working directory in the container
ENV PATH=/usr/local/nginx/bin:$PATH
EXPOSE $APP_PORT

WORKDIR /app

# Install dependencies required for managing permissions and timezone
RUN apt-get update && apt-get install -y --no-install-recommends \
tini \
gosu \
tzdata \
# && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
# && apt-get install -y nodejs \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# https://github.com/nikolaik/docker-python-nodejs
# All images have a default user `pn`` with uid 1000 and gid 1000.
# Create the appuser user and group before setting permissions
# RUN groupadd -g 1000 appuser && \
# useradd -m -u 1000 -g appuser -s /bin/bash appuser

# Copy the application's requirements.txt and setup script, then install Python dependencies
# COPY ./requirements.txt ./
# RUN pip install --no-cache-dir -r requirements.txt
COPY --chown=pn:pn ./ /app

# Copy the rest of the application's source code
COPY ./ /app
RUN cd "/app/frontend/palworld-pal-editor-webui" \
&& npm install \
&& npm run build \
&& mv "/app/frontend/palworld-pal-editor-webui/dist" "/app/src/palworld_pal_editor/webui"

# Copy the entrypoint script into the image and make it executable
COPY ./docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
RUN chmod +x /app/setup_and_run.sh
RUN pip install --no-cache-dir -r requirements.txt \
&& pip install -e .

ENTRYPOINT ["/entrypoint.sh"]

# Expose the port dynamically
EXPOSE $APP_PORT
RUN chmod +x /app/docker/app.sh

CMD ["./setup_and_run.sh"]
CMD ["/app/docker/app.sh"]
18 changes: 18 additions & 0 deletions docker/app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [ ! -z "$PUID" ] && [ ! -z "$PGID" ]; then
usermod -u $PUID pn
groupmod -g $PGID pn
fi

cmd="python -m palworld_pal_editor --nocli"

if [ -n "$APP_LANG" ]; then cmd="$cmd --lang=\"$APP_LANG\""; fi
if [ -n "$APP_PORT" ]; then cmd="$cmd --port=$APP_PORT"; fi
if [ -n "$MODE" ]; then cmd="$cmd --mode=\"$MODE\""; fi
if [ -n "$SAVE_PATH" ]; then cmd="$cmd --path=\"$SAVE_PATH\""; fi
if [ -n "$PASSWORD" ]; then cmd="$cmd --password=\"$PASSWORD\""; fi

echo "Launching: $cmd"

eval "$cmd"
32 changes: 0 additions & 32 deletions docker/entrypoint.sh

This file was deleted.

1 change: 0 additions & 1 deletion docker/sample-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ services:
ports:
- 58888:58888
environment:
- TZ=UTC
- PUID=1000 # change this to your uid
- PGID=1000
- APP_PORT=58888 # make sure this matches the port you are going to map
Expand Down

0 comments on commit a04a6e0

Please sign in to comment.