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

Remove old compiled spt3g/so3g layers from Docker image #397

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
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
23 changes: 18 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
# A container setup with an installation of ocs.

# Use ubuntu base image
FROM simonsobs/so3g:v0.1.3-13-g5471f0d
FROM ubuntu:22.04

# Set timezone to UTC
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Set locale
ENV LANG C.UTF-8
Expand All @@ -22,26 +26,35 @@ ENV OCS_CONFIG_DIR=/config
ENV PYTHONUNBUFFERED=1

# Install python and pip
RUN apt-get update && apt-get install -y python3 \
RUN apt-get update && apt-get install -y \
git \
python3 \
python3-pip \
python3-virtualenv \
python-is-python3 \
vim

# Setup virtualenv
RUN python -m virtualenv /opt/venv/
ENV PATH="/opt/venv/bin:$PATH"
RUN python -m pip install -U pip

# Install init system
RUN pip3 install dumb-init
RUN python -m pip install dumb-init

# Copy in and install requirements
# This will leverage the cache for rebuilds when modifying OCS, avoiding
# downloading all the requirements again
COPY requirements/ /app/ocs/requirements
COPY requirements.txt /app/ocs/requirements.txt
WORKDIR /app/ocs/
RUN pip3 install -r requirements.txt
RUN python -m pip install -r requirements.txt

# Copy the current directory contents into the container at /app
COPY . /app/ocs/

# Install ocs
RUN pip3 install .
RUN python -m pip install .

# Reset workdir to avoid local imports
WORKDIR /
Expand Down
13 changes: 9 additions & 4 deletions docs/developer/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ OCS Agent via ``ocs-agent-cli``. See the `Dockerfile reference
<https://docs.docker.com/engine/reference/builder/>`_ in the Docker
documentation for more information about how to write a Dockerfile.

.. note::

``ocs`` and its dependencies are installed into a ``virutualenv`` kept in
``/opt/venv/``. This is enabled by putting ``/opt/venv/bin/`` at the front of
the PATH. This is in place to isolate the installation from the system Python.

Building Upon the Base Image
----------------------------

Expand All @@ -43,19 +49,18 @@ that looks something like:
# Install required dependencies
RUN apt-get update && apt-get install -y rsync \
wget \
python3-pip
wget
# Copy in and install requirements
COPY requirements.txt /app/my-ocs-agent/requirements.txt
WORKDIR /app/my-ocs-agent/
RUN pip3 install -r requirements.txt
RUN python -m pip install -r requirements.txt
# Copy the current directory contents into the container at /app
COPY . /app/my-ocs-agent/
# Install my-ocs-agent
RUN pip3 install .
RUN python -m pip install .
# Run agent on container startup
ENTRYPOINT ["dumb-init", "ocs-agent-cli"]
Expand Down