Skip to content

Commit

Permalink
Embed entrypoint in docker image (#210)
Browse files Browse the repository at this point in the history
* Embed entrypoint in docker image

* Pin snitch_cluster fork commit
  • Loading branch information
nazavode authored Apr 7, 2024
1 parent d8e3992 commit 88f979f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
6 changes: 4 additions & 2 deletions snitch/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ FROM ghcr.io/pulp-platform/snitch_cluster@sha256:9978f9d0e3e6b7ad1b2c1f0eb628a11

RUN git clone --recursive https://github.com/nazavode/snitch_cluster.git /src \
&& cd /src \
&& git checkout nazavode/xdsl-ci \
&& git reset --hard 6c63f4c65d115ce16193f4f9a030ac08416a4acf \
&& git submodule update \
# verilator model
&& cd /src/target/snitch_cluster \
&& make CFG_OVERRIDE=cfg/fdiv.hjson bin/snitch_cluster.vlt \
Expand Down Expand Up @@ -102,4 +103,5 @@ deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-16 main\n" >> /etc/apt
# Make our own python3.11 available for current $USER:
ENV PATH "/opt/python3.11/bin:${PATH}"

ENTRYPOINT ["/src/snitch/docker/entrypoint.sh"]
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
29 changes: 16 additions & 13 deletions snitch/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

VENV_DIR=venv_docker
FORCE_VENV=0

pushd /src/xdsl > /dev/null

if [[ 1 -eq ${FORCE_VENV} ]] || [[ ! -d ${VENV_DIR} ]] || [[ ! -f ${VENV_DIR}/bin/activate ]]; then
python3 -m venv ${VENV_DIR}
source ${VENV_DIR}/bin/activate

pip install -e .
pip install pandas
else
source ${VENV_DIR}/bin/activate
# This entrypoint expects the source repo to be mounted at /src,
# if this is not the case, just skip xdsl virtualenv creation.
if [[ -d /src/xdsl ]]; then
pushd /src/xdsl > /dev/null
if [[ 1 -eq ${FORCE_VENV} ]] || [[ ! -d ${VENV_DIR} ]] || [[ ! -f ${VENV_DIR}/bin/activate ]]; then
python3 -m venv ${VENV_DIR}
source ${VENV_DIR}/bin/activate
pip install -e .
pip install pandas
else
source ${VENV_DIR}/bin/activate
fi
popd
fi

popd

exec "$@"

0 comments on commit 88f979f

Please sign in to comment.