-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from entelecheia/entelecheia/issue82
- Loading branch information
Showing
12 changed files
with
240 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Sets the base image for subsequent instructions | ||
ARG ARG_BUILD_FROM="ghcr.io/entelecheia/hyperfast-docker:latest-base" | ||
FROM $ARG_BUILD_FROM | ||
|
||
# Setting ARGs and ENVs for user creation and workspace setup | ||
ARG ARG_USERNAME="app" | ||
ARG ARG_USER_UID=9001 | ||
ARG ARG_USER_GID=$ARG_USER_UID | ||
ARG ARG_WORKSPACE_ROOT="/workspace" | ||
ENV USERNAME $ARG_USERNAME | ||
ENV USER_UID $ARG_USER_UID | ||
ENV USER_GID $ARG_USER_GID | ||
ENV WORKSPACE_ROOT $ARG_WORKSPACE_ROOT | ||
|
||
# Creates a non-root user with sudo privileges | ||
USER root | ||
# check if user exists and if not, create user | ||
RUN if id -u $USERNAME >/dev/null 2>&1; then \ | ||
echo "User exists"; \ | ||
else \ | ||
groupadd --gid $USER_GID $USERNAME && \ | ||
adduser --uid $USER_UID --gid $USER_GID --force-badname --disabled-password --gecos "" $USERNAME && \ | ||
echo "$USERNAME:$USERNAME" | chpasswd && \ | ||
adduser $USERNAME sudo && \ | ||
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \ | ||
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME && \ | ||
chmod 0440 /etc/sudoers.d/$USERNAME; \ | ||
fi | ||
|
||
# Switches to the newly created user | ||
USER $USERNAME | ||
# Sets up the workspace for the user | ||
RUN sudo rm -rf $WORKSPACE_ROOT && sudo mkdir -p $WORKSPACE_ROOT/projects | ||
RUN sudo chown -R $USERNAME:$USERNAME $WORKSPACE_ROOT | ||
|
||
# Adds .local/bin to PATH | ||
ENV PATH="/home/$USERNAME/.local/bin:${PATH}" | ||
# Sets Python environment variables | ||
ENV PIP_DEFAULT_TIMEOUT 100 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
# Sets the time zone within the container | ||
ENV TZ="Asia/Seoul" | ||
|
||
|
||
|
||
# Sets the working directory to workspace root | ||
WORKDIR $WORKSPACE_ROOT | ||
# Copies scripts from host into the image | ||
COPY ./.docker/scripts/ ./scripts/ | ||
# Installs Python dependencies listed in requirements.txt | ||
RUN pip3 install -r ./scripts/requirements.txt | ||
|
||
# Setting ARGs and ENVs for Stable-Diffusion-WebUI GitHub repository | ||
ARG ARG_APP_SOURCE_REPO="entelecheia/entelecheia" | ||
ARG ARG_APP_INSTALL_ROOT="/workspace/projects" | ||
ARG ARG_APP_CLONE_DIRNAME="entelecheia/entelecheia" | ||
ARG ARG_APP_SOURCE_BRANCH="main" | ||
ARG ARG_APP_SERVICE_NAME="app" | ||
ENV APP_SOURCE_REPO $ARG_APP_SOURCE_REPO | ||
ENV APP_INSTALL_ROOT $ARG_APP_INSTALL_ROOT | ||
ENV APP_CLONE_DIRNAME $ARG_APP_CLONE_DIRNAME | ||
ENV APP_SOURCE_BRANCH $ARG_APP_SOURCE_BRANCH | ||
ENV APP_SERVICE_NAME $ARG_APP_SERVICE_NAME | ||
|
||
# Specifies the command that will be executed when the container is run | ||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Sets the base image for subsequent instructions | ||
ARG ARG_BUILD_FROM="python:3.9-slim-bookworm" | ||
FROM $ARG_BUILD_FROM | ||
|
||
# Sets labels for the image | ||
LABEL org.opencontainers.image.source="https://github.com/entelecheia/hyperfast-docker-template" | ||
LABEL org.opencontainers.image.description="Hyperfast Docker Template is a powerful tool that leverages copier to streamline the creation of new Docker projects. It simplifies and accelerates Docker configurations, fostering a highly efficient and user-friendly development experience." | ||
LABEL org.opencontainers.image.licenses="MIT" | ||
|
||
# Setting this argument prevents interactive prompts during the build process | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
# Updates the image and installs necessary packages | ||
RUN apt-get update --fix-missing \ | ||
&& apt-get install -y curl wget jq sudo \ | ||
# !! Without python3-launchpadlib, software-properties-common fails to install | ||
python3-launchpadlib software-properties-common \ | ||
locales locales-all fontconfig fonts-nanum \ | ||
tzdata openssh-server \ | ||
# Adds PPA for the latest git version | ||
&& add-apt-repository ppa:git-core/ppa -y \ | ||
&& apt-get update \ | ||
&& apt-get -y install --no-install-recommends git \ | ||
# Cleans up unnecessary packages to reduce image size | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y | ||
|
||
# Installs the latest pip and setuptools from PyPI | ||
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ | ||
&& python3 get-pip.py \ | ||
&& rm get-pip.py | ||
# Sets Python environment variables | ||
ENV PIP_DEFAULT_TIMEOUT 100 | ||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Sets the working directory to workspace root | ||
ARG ARG_WORKSPACE_ROOT="/workspace" | ||
ENV WORKSPACE_ROOT $ARG_WORKSPACE_ROOT | ||
# Sets up the workspace for the user | ||
RUN rm -rf $WORKSPACE_ROOT && mkdir -p $WORKSPACE_ROOT/projects | ||
WORKDIR $WORKSPACE_ROOT | ||
# Copies scripts from host into the image | ||
COPY ./.docker/scripts/ ./scripts/ | ||
RUN if [ -f ./scripts/requirements-base.txt ]; then pip3 install -r ./scripts/requirements-base.txt; fi | ||
|
||
# Sets the time zone within the container | ||
ENV TZ="Asia/Seoul" | ||
# Sets up the locale to en_US.UTF-8 | ||
RUN localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 || true | ||
|
||
# Setting ARGs and ENVs for user creation and workspace setup | ||
ARG ARG_USERNAME="app" | ||
ARG ARG_USER_UID=9001 | ||
ARG ARG_USER_GID=$ARG_USER_UID | ||
ENV USERNAME $ARG_USERNAME | ||
ENV USER_UID $ARG_USER_UID | ||
ENV USER_GID $ARG_USER_GID | ||
|
||
# Creates a non-root user with sudo privileges | ||
RUN groupadd --gid $USER_GID $USERNAME \ | ||
&& adduser --uid $USER_UID --gid $USER_GID --force-badname --disabled-password --gecos "" $USERNAME \ | ||
&& echo "$USERNAME:$USERNAME" | chpasswd \ | ||
&& adduser $USERNAME sudo \ | ||
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ | ||
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \ | ||
&& chmod 0440 /etc/sudoers.d/$USERNAME | ||
|
||
|
||
|
||
|
||
# Specifies the command that will be executed when the container is run | ||
CMD ["bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: "3" | ||
|
||
services: | ||
# Defines a service name | ||
workspace: | ||
build: | ||
# Sets the build context to the current directory | ||
context: . | ||
# Specifies the Dockerfile to use for the build | ||
dockerfile: .docker/Dockerfile.base | ||
# Specifies build-time variables (ARGs) | ||
args: | ||
ARG_BUILD_FROM: $BUILD_FROM | ||
ARG_USERNAME: $CONTAINER_USERNAME | ||
ARG_USER_UID: $CONTAINER_USER_UID | ||
ARG_USER_GID: $CONTAINER_USER_GID | ||
ARG_WORKSPACE_ROOT: $CONTAINER_WORKSPACE_ROOT | ||
ARG_WORKSPACE_LOCATION: $CONTAINER_WORKSPACE_LOCATION | ||
ARG_SYSTEM_HOSTNAME: $CONTAINER_HOSTNAME | ||
# Sets the image name for the built image | ||
image: $IMAGE_NAME:$IMAGE_TAG | ||
# Sets the hostname of the container | ||
hostname: $CONTAINER_HOSTNAME | ||
command: | ||
# Specifies the command to be executed when the container is run | ||
- $CONTAINER_RUN_COMMAND | ||
ulimits: | ||
# Sets the stack size and memory lock limits | ||
stack: 67108864 | ||
memlock: -1 | ||
ipc: $CONTAINER_IPC | ||
networks: | ||
default: | ||
# Sets the name of the default network and makes it external | ||
name: $CONTAINER_NETWORK_NAME | ||
external: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
####################################################################################### | ||
# Please do not make any changes below this line if you don't know what you are doing # | ||
# change the variables above to your need # | ||
####################################################################################### | ||
# docker build: Configuration parameters for building the Docker image | ||
BASE_VARIANT=${BASE_VARIANT:-"base"} # The variant of the Docker image. | ||
IMAGE_TAG="${IMAGE_VERSION}-${BASE_VARIANT}" # The tag of the Docker image | ||
IMAGE_NAME="${CONTAINER_REGISTRY}/${DOCKER_USERNAME}/${DOCKER_PROJECT_NAME}" # The full name of the Docker image | ||
BUILD_FROM="python:3.9-slim-bookworm" # The base image for the Docker build |