Skip to content

Commit

Permalink
Fix timeout usage and document some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend committed May 16, 2024
1 parent aa89ef3 commit e9378ee
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
17 changes: 15 additions & 2 deletions docker/dev_env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
FROM docker.io/library/alpine:latest

# Dependency explanations
# - git: required by some python package; contributors should use git on their host
# - coreutils: required for timeout (maybe other utils too) because busybox's doesn't match our usage
# - perl: used in linting
# - bash: used for scripts
# - curl: used by scripts
# - python3: self-explanatory
# - pipx: used to install pipenv in the entrypoint, we can remove this after switching fully to pdm
# - docker*: used to interact with host docker socket
# - nodejs-current: self-explanatory
# - npm: required by pre-commit environment to be explicitly installed along with node
# - just: command runner
RUN apk add --update --no-cache \
git \
coreutils \
perl \
bash \
openssh \
gnupg \
curl \
python3 \
pipx \
Expand All @@ -20,6 +31,8 @@ RUN apk add --update --no-cache \
addgroup opener docker; \
corepack enable;

# pipenv, pnpm, and pdm are installed in the entrypoint

COPY entrypoint.sh /entrypoint.sh

WORKDIR /ov
Expand Down
2 changes: 2 additions & 0 deletions docker/dev_env/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /usr/bin/env bash

set -e

if [ "$(whoami)" != "opener" ]; then
printf "Do not run this container with the root user! Use the 'run.sh' script or pass --user to docker run.\n"
exit 1
Expand Down
8 changes: 7 additions & 1 deletion docker/dev_env/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ run_args=(
--env "TERM=xterm-256color"
--user "$UID:$host_docker_gid"
--network host
# Bind the repo to the same exact location inside the container so that pre-commit
# and others don't get confused about where files are supposed to be
--mount "type=bind,source=$OPENVERSE_PROJECT,target=$OPENVERSE_PROJECT"
# Save the home directory of the container so we can reuse it each time
--mount "type=volume,src=openverse-dev-env,target=$opener_home"
# Expose the host's docker socket to the container so the container can run docker/compose etc
-v /var/run/docker.sock:/var/run/docker.sock
)

if [ -t 0 ]; then
run_args+=(-t)
fi

# Git commit can be mapped, but you won't be able to sign commits inside the
# Git config can be mapped, but you won't be able to sign commits inside the
# container. Use your host `git` in that case, please!
for git_config in /etc/gitconfig "$HOME"/.gitconfig "$XDG_CONFIG_HOME"/git; do
if [ -a "$git_config" ]; then
Expand All @@ -38,6 +42,7 @@ done

host_pnpm_store="$(pnpm store path 2>/dev/null || echo)"

# Share the pnpm cache with the container, if it's available locally
if [ "$host_pnpm_store" != "" ]; then
pnpm_home="$(dirname "$host_pnpm_store")"
run_args+=(
Expand All @@ -46,6 +51,7 @@ if [ "$host_pnpm_store" != "" ]; then
)
fi

# Share the PDM cache with the container, if it's available locally
if [ "$(pdm config install.cache)" == "True" ]; then
host_pdm_cache="$(pdm config cache_dir)"
run_args+=(
Expand Down

0 comments on commit e9378ee

Please sign in to comment.