Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing compatibility and remove DOCKER_BUILDKIT in the Docker setup #815

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,44 @@
FROM python:3.10.6

# Build the image and name it workbench-docker-image-name (or whatever you want)
# docker build -t workbench-docker-image-name .
# docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) -t workbench-docker .

# Build the container from the built image and run workbench:
# docker run -it --rm --network="host" -v $(pwd):/workbench --name workbench-docker-container-name workbench-docker-image-name bash -lc "(./workbench --config example.yml --check)"
# docker run -it --rm --network="host" -v $(pwd)/islandora_workbench:/workbench --name workbench-docker-container-name workbench-docker-image-name bash -lc "./workbench --config /workbench/islandora_workbench_demo_content/example.yml --check"
# docker run -it --rm --network="host" -v .:/workbench --name update_existing_objects workbench-docker bash -lc "./workbench --config /workbench/prod/update_islandora_objects.yml --check"
# Another example but with mounted directories for the migration to have access to.
# docker run -it --rm --network="host" -v .:/workbench -v /path/to/your/tmp:/tmp -v /path/to/your/files:/mnt/data/local --name update_existing_objects workbench-docker bash -lc "./workbench --config /workbench/prod/update_islandora_objects.yml --check"
# To export a CSV file, that includes the available Drupal fields, run:
# docker run -it --rm --network="host" -v $(pwd)/islandora_workbench:/workbench --name workbench-docker-container-name workbench-docker-image-name bash -lc "./workbench --config /workbench/islandora_workbench_demo_content/idc_example_geo.yml --get_csv_template"
# docker run -it --rm --network="host" -v .:/workbench --name workbench-docker-container-name workbench-docker-image-name bash -lc "./workbench --config /workbench/islandora_workbench_demo_content/idc_example_geo.yml --get_csv_template"
# The directory this file is in is mounted within the container at /workbench
# Rename example.yml to your YML file.

ADD . /workbench/
# Create a non-root user and set up the environment
ARG USER_ID
ARG GROUP_ID

# Create a group with the specified GID
RUN groupadd -g $GROUP_ID dockeruser || true

# Create a user with the specified UID and GID
RUN useradd -m -u $USER_ID -g $GROUP_ID -s /bin/bash dockeruser

# Set the working directory
WORKDIR /workbench

# Works with and without this line
RUN python -m pip install setuptools libmagic urllib3>=1.21.1
# Copy the current directory contents into the container at /workbench
COPY . /workbench/

# Set ownership and permissions for the non-root user
RUN chown -R dockeruser:dockeruser /workbench

# Set the PATH environment variable to include .local/bin
ENV PATH=/home/dockeruser/.local/bin:$PATH

# Switch to the non-root user
USER dockeruser

RUN python setup.py install
# Install dependencies and setup the environment
RUN python -m pip install --user --upgrade pip setuptools build && \
python -m pip install --user --no-cache-dir "urllib3>=1.21.1" libmagic && \
python -m build && \
python -m pip install --user dist/*.whl