Skip to content

Commit

Permalink
More Docker cleanup (#1068)
Browse files Browse the repository at this point in the history
    PANUSER owns conda.
    Dockerfile cleanup for better builds.
    Docker image does not contain focuser extras by default. #1068
    Move all tests into tests subdir from project root.
    Cleanup of testing setup, especially for GHA.
    Fix testing log level.
  • Loading branch information
wtgee authored Jan 22, 2021
1 parent 2c8ed14 commit cb4d26e
Show file tree
Hide file tree
Showing 32 changed files with 42 additions and 17 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ Changelog
[0.7.dev8]
----------

Docker
~~~~~~

* ``PANUSER`` owns ``conda``. #1068
* Dockerfile cleanup for better builds. #1068
* Docker image does not contain ``focuser`` extras by default. #1068

Testing
~~~~~~~

* Fix the log level in conftest. #1068
* Move all tests into ``tests`` subdir from project root. #1068
* Cleanup of testing setup, especially for GHA. #1068

[0.7.7] - 2021-01-19
--------------------
Expand Down
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
TESTING_LOG_LEVEL = 'TRACE'
LOGGER_INFO = PanLogger()

logger = get_logger(console_log_file=TESTING_LOG_LEVEL)
logger = get_logger(console_log_level=TESTING_LOG_LEVEL)
logger.enable('panoptes')
# Add a level above TRACE and below DEBUG
logger.level("testing", no=15, icon="🤖", color="<LIGHT-BLUE><white>")
Expand Down
42 changes: 26 additions & 16 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ARG panuser=pocs-user
ARG userid=1000
ARG pan_dir=/var/panoptes
ARG pocs_dir="${pan_dir}/POCS"
ARG pip_install_extras="[google,testing]"

ENV PANUSER $panuser
ENV USERID $userid
ENV PANDIR $pan_dir
ENV POCS $pocs_dir

# Install system dependencies.
RUN apt-get update && apt-get install --no-install-recommends --yes \
Expand All @@ -26,35 +29,42 @@ RUN apt-get update && apt-get install --no-install-recommends --yes \
useradd -u ${USERID} -o -c "PANOPTES POCS" \
-p panoptes -m -G plugdev,dialout,users,sudo ${PANUSER} && \
# Allow sudo without password.
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
# Setup SSH so localhost works without password
mkdir -p "/home/${panuser}/.ssh" && \
echo "Host localhost\n\tStrictHostKeyChecking no\n" >> "/home/${panuser}/.ssh/config"

USER "${userid}"

# Miniconda
WORKDIR /tmp
RUN wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" \
RUN echo "Installing conda via miniforge" && \
sudo mkdir -p /conda && \
sudo chown -R "${PANUSER}:${PANUSER}" /conda && \
# Miniforge
wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-$(uname -m).sh" \
-O install-miniforge.sh && \
/bin/sh /tmp/install-miniforge.sh -b -f -p /conda && \
/bin/sh install-miniforge.sh -b -f -p /conda && \
# Initialize conda for the shells.
/conda/bin/conda init bash

COPY environment.yaml .
RUN /conda/bin/conda env update -n base -f environment.yaml && \
ENV PATH "/home/${PANUSER}/.local/bin:$PATH"

RUN echo "Setting up filesystem and installing conda." && \
# Create PANOPTES directories.
mkdir -p ${PANDIR} && \
sudo mkdir -p ${PANDIR} && \
sudo chown -R "${PANUSER}:${PANUSER}" ${PANDIR} && \
mkdir -p ${PANDIR}/logs && \
mkdir -p ${PANDIR}/images
mkdir -p ${PANDIR}/images && \
mkdir -p ${POCS}

ARG pocs_dir="${PANDIR}/POCS"
ENV POCS $pocs_dir
ENV PATH "/home/${PANUSER}/.local/bin:$PATH"

ARG pip_extras="[google,testing]"
COPY environment.yaml .
RUN /conda/bin/conda env update -n base -f environment.yaml

USER "${userid}"
WORKDIR "${POCS}"
COPY --chown="${userid}:${userid}" . .
RUN echo "Installing editable module with ${pip_extras}" && \
sudo chown -R ${PANUSER}:${PANUSER} ${PANDIR} && \
/conda/bin/pip install -e ".${pip_extras}" && \
RUN echo "Installing editable module with ${pip_install_extras}" && \
/conda/bin/pip install -e ".${pip_install_extras}" && \
# Remove git folder
rm -rf "${POCS}/.git" && \
# Cleanup
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ services:
PANOPTES_CONFIG_FILE:
volumes:
- pocsdir:/var/panoptes/POCS
- /var/panoptes/logs:/var/panoptes/logs
# No-op to keep machine running, use $POCS/bin/pocs-shell to access
command: [ "wait-for-it ${PANOPTES_CONFIG_PORT}:${PANOPTES_CONFIG_PORT} -- echo POCS yo!" ]
volumes:
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ extras = True
addopts =
--cov panoptes.pocs
--cov panoptes.peas
--cov tests
--cov-branch
--cov-report term-missing:skip-covered
--cov-report xml:build/coverage.xml
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit cb4d26e

Please sign in to comment.