chore: make dev container use base image

This commit is contained in:
Nicolas Giard 2022-05-24 16:49:37 -04:00 committed by GitHub
parent 53c1377717
commit 742ce5a08e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 140 deletions

View file

@ -102,5 +102,5 @@
// "postCreateCommand": "sh /docker-init.sh",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"remoteUser": "dev"
}

View file

@ -5,12 +5,6 @@ services:
build:
context: .
dockerfile: docker/app.Dockerfile
args:
# Update 'VARIANT' to pick a version of Python: 3, 3.10, 3.9, 3.8, 3.7, 3.6
# Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: 3.9-bullseye
NODE_VERSION: '16'
init: true
@ -33,7 +27,7 @@ services:
# DJANGO_SETTINGS_MODULE: settings_sqlitetest
# Uncomment the next line to use a non-root user for all processes.
# user: vscode
# user: dev
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

View file

@ -1,8 +1,4 @@
# Based on image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.236.0/containers/python-3/.devcontainer/base.Dockerfile
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT=3-bullseye
FROM python:${VARIANT}
FROM ghcr.io/ietf-tools/datatracker-app-base:latest
LABEL maintainer="IETF Tools Team <tools-discuss@ietf.org>"
ENV DEBIAN_FRONTEND=noninteractive
@ -17,7 +13,7 @@ ARG INSTALL_ZSH="true"
# [Option] Upgrade OS packages to their latest versions
ARG UPGRADE_PACKAGES="true"
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
ARG USERNAME=vscode
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
@ -32,145 +28,23 @@ ENV PIPX_HOME=/usr/local/py-utils \
ENV PATH=${PATH}:${PIPX_BIN_DIR}
RUN bash /tmp/library-scripts/python-debian.sh "none" "/usr/local" "${PIPX_HOME}" "${USERNAME}"
# [Choice] Node.js version: lts, 18, 16, 14, 12, 10
ARG NODE_VERSION="16"
RUN curl -fsSL "https://deb.nodesource.com/setup_${NODE_VERSION}.x" | bash -
RUN apt-get install -y nodejs make gcc g++ && npm install -g yarn
# Remove library scripts for final image
RUN rm -rf /tmp/library-scripts
# Expose port 8000
EXPOSE 8000
# Add Docker Source
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install the packages we need
RUN apt-get update --fix-missing && apt-get install -qy \
apache2-utils \
apt-file \
apt-utils \
bash \
build-essential \
curl \
default-jdk \
docker-ce-cli \
enscript \
fish \
gawk \
gcc \
ghostscript \
git \
gnupg \
graphviz \
jq \
less \
libcairo2-dev \
libgtk2.0-0 \
libgtk-3-0 \
libnotify-dev \
libgconf-2-4 \
libgbm-dev \
libnss3 \
libxss1 \
libasound2 \
libxtst6 \
libmagic-dev \
libmariadb-dev \
libmemcached-tools \
locales \
mariadb-client \
memcached \
netcat \
nano \
pigz \
pv \
python3-ipython \
ripgrep \
rsync \
rsyslog \
ruby \
ruby-rubygems \
subversion \
unzip \
watchman \
wget \
xauth \
xvfb \
yang-tools \
zsh
# Install kramdown-rfc2629 (ruby)
RUN gem install kramdown-rfc2629
# Install chromedriver if supported
COPY docker/scripts/app-install-chromedriver.sh /tmp/app-install-chromedriver.sh
RUN sed -i 's/\r$//' /tmp/app-install-chromedriver.sh && \
chmod +x /tmp/app-install-chromedriver.sh
RUN /tmp/app-install-chromedriver.sh
# Fix /dev/shm permissions for chromedriver
RUN chmod 1777 /dev/shm
# Get rid of installation files we don't need in the image, to reduce size
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
# "fake" dbus address to prevent errors
# https://github.com/SeleniumHQ/docker-selenium/issues/87
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
# avoid million NPM install messages
ENV npm_config_loglevel warn
# allow installing when the main user is root
ENV npm_config_unsafe_perm true
# disable NPM funding messages
ENV npm_config_fund false
# Set locale to en_US.UTF-8
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment && \
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
echo "LANG=en_US.UTF-8" > /etc/locale.conf && \
dpkg-reconfigure locales && \
locale-gen en_US.UTF-8 && \
update-locale LC_ALL en_US.UTF-8
ENV LC_ALL en_US.UTF-8
# Install idnits
ADD https://raw.githubusercontent.com/ietf-tools/idnits-mirror/main/idnits /usr/local/bin/
RUN chmod +rx /usr/local/bin/idnits
# Turn off rsyslog kernel logging (doesn't work in Docker)
RUN sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
# Colorize the bash shell
RUN sed -i 's/#force_color_prompt=/force_color_prompt=/' /root/.bashrc
ADD https://raw.githubusercontent.com/eficode/wait-for/v2.1.3/wait-for /usr/local/bin/
RUN chmod +rx /usr/local/bin/wait-for
# Copy the startup file
COPY docker/scripts/app-init.sh /docker-init.sh
RUN sed -i 's/\r$//' /docker-init.sh && \
chmod +x /docker-init.sh
# Create workspace
RUN mkdir -p /workspace
WORKDIR /workspace
# Fix user UID / GID to match host
RUN groupmod --gid $USER_GID $USERNAME \
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
&& chown -R $USER_UID:$USER_GID /home/$USERNAME \
|| exit 0
USER vscode:vscode
USER dev:dev
# Install current datatracker python dependencies
COPY requirements.txt /tmp/pip-tmp/
RUN pip3 --disable-pip-version-check --no-cache-dir install --user --no-warn-script-location -r /tmp/pip-tmp/requirements.txt
RUN sudo rm -rf /tmp/pip-tmp
# ENTRYPOINT [ "/docker-init.sh" ]

View file

@ -64,6 +64,7 @@ RUN apt-get update --fix-missing && apt-get install -qy \
ruby \
ruby-rubygems \
unzip \
watchman \
wget \
xauth \
xvfb \

View file

@ -6,8 +6,8 @@ sudo service rsyslog start
# Fix ownership of volumes
echo "Fixing volumes ownership..."
sudo chown -R vscode:vscode "$WORKSPACEDIR/.parcel-cache"
sudo chown -R vscode:vscode "$WORKSPACEDIR/__pycache__"
sudo chown -R dev:dev "$WORKSPACEDIR/.parcel-cache"
sudo chown -R dev:dev "$WORKSPACEDIR/__pycache__"
# Build node packages that requrie native compilation
echo "Compiling native node packages..."
@ -73,7 +73,7 @@ fi
# Run memcached
echo "Starting memcached..."
/usr/bin/memcached -u vscode -d
/usr/bin/memcached -u dev -d
# Initial checks