Skip to content

Commit

Permalink
Merge pull request #86 from entelecheia/entelecheia/issue81
Browse files Browse the repository at this point in the history
  • Loading branch information
entelecheia authored Oct 9, 2023
2 parents 9cc7422 + 7b9551b commit db7eead
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .copier-docker-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; do NOT edit manually
_commit: v0.22.1-5-gefff48c
_commit: v0.22.1-8-g5c34c5c
_src_path: .
app_clone_dirname: entelecheia/entelecheia
app_install_root: /workspace/projects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,35 @@ RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& `{{ python_command }}` get-pip.py \
&& rm get-pip.py
{%- endif %}
# 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
{% if copy_scripts_dir -%}
# Copies scripts from host into the image
COPY ./.docker/scripts/ ./scripts/
RUN if [ -f ./scripts/requirements-base.txt ]; then `{{ pip_command }}` install -r ./scripts/requirements-base.txt; fi
{%- endif %}

# Sets the time zone within the container
ENV TZ="`{{ docker_timezone }}`"
# Sets up the locale to en_US.UTF-8
RUN localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 || true
# Fixes sudo error related to core dumps
RUN echo "Set disable_coredump false" > /etc/sudo.conf

# Setting ARGs and ENVs for user creation and workspace setup
ARG ARG_USERNAME="`{{ docker_container_username }}`"
ARG ARG_USER_UID=`{{ docker_container_uid }}`
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
RUN groupadd --gid $USER_GID $USERNAME \
Expand All @@ -54,22 +69,14 @@ RUN groupadd --gid $USER_GID $USERNAME \
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME


{% if install_dotfiles -%}
# Fixes sudo error related to core dumps
RUN echo "Set disable_coredump false" > /etc/sudo.conf

# 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="`{{ docker_timezone }}`"

{% if install_dotfiles -%}
# install dotfiles
ARG ARG_USER_FULLNAME="Dev User"
ARG ARG_USER_EMAIL="dev@domain.com"
Expand All @@ -92,14 +99,8 @@ USER $USERNAME
RUN sudo rm -rf $WORKSPACE_ROOT && sudo mkdir -p $WORKSPACE_ROOT
RUN sudo chown -R $USERNAME:$USERNAME $WORKSPACE_ROOT
RUN sh -c "$(wget -qO- https://dotfiles.entelecheia.ai/install)"
{%- endif %}

# Sets the working directory to workspace root
WORKDIR $WORKSPACE_ROOT
{% if copy_scripts_dir -%}
# Copies scripts from host into the image
COPY ./.docker/scripts/ ./scripts/
RUN if [ -f ./scripts/requirements-base.txt ]; then `{{ pip_command }}` install -r ./scripts/requirements-base.txt; fi
RUN sudo chown -R $USERNAME:$USERNAME $WORKSPACE_ROOT
{%- endif %}

# Specifies the command that will be executed when the container is run
Expand Down
43 changes: 22 additions & 21 deletions .docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,33 @@ RUN apt-get update --fix-missing \
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
# Fixes sudo error related to core dumps
RUN echo "Set disable_coredump false" > /etc/sudo.conf

# 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
RUN groupadd --gid $USER_GID $USERNAME \
Expand All @@ -52,20 +65,12 @@ RUN groupadd --gid $USER_GID $USERNAME \
&& echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME


# Fixes sudo error related to core dumps
RUN echo "Set disable_coredump false" > /etc/sudo.conf

# 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"

# install dotfiles
ARG ARG_USER_FULLNAME="Dev User"
Expand All @@ -90,11 +95,7 @@ RUN sudo rm -rf $WORKSPACE_ROOT && sudo mkdir -p $WORKSPACE_ROOT
RUN sudo chown -R $USERNAME:$USERNAME $WORKSPACE_ROOT
RUN sh -c "$(wget -qO- https://dotfiles.entelecheia.ai/install)"

# Sets the working directory to workspace root
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
RUN sudo chown -R $USERNAME:$USERNAME $WORKSPACE_ROOT

# Specifies the command that will be executed when the container is run
CMD ["bash"]
2 changes: 1 addition & 1 deletion tmp/.copier-docker-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier; do NOT edit manually
_commit: v0.22.1-5-gda763d3
_commit: v0.22.1-7-gc101bef
_src_path: .
app_clone_dirname: entelecheia/entelecheia
app_install_root: /workspace/projects
Expand Down

0 comments on commit db7eead

Please sign in to comment.