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

Dockerfile lint #689

Merged
merged 14 commits into from
Jun 20, 2023
57 changes: 57 additions & 0 deletions .github/workflows/docker-verify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Docker verify process
Tansito marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
Tansito marked this conversation as resolved.
Show resolved Hide resolved

env:
HADOLINT_DOCKER_IMAGE: hadolint/hadolint:v2.12.0

defaults:
run:
working-directory: ./infrastructure/docker

jobs:
gateway-lint:
Tansito marked this conversation as resolved.
Show resolved Hide resolved
name: gateway lint
runs-on: ubuntu-latest

env:
DOCKER_FILE: Dockerfile-gateway

steps:
- uses: actions/checkout@v3
- name: Run lint on gateway's Dockerfile
run: docker run --name hadolint --rm --interactive ${{env.HADOLINT_DOCKER_IMAGE}} < ${{env.DOCKER_FILE}}
notebook-lint:
name: notebook lint
runs-on: ubuntu-latest

env:
DOCKER_FILE: Dockerfile-notebook

steps:
- uses: actions/checkout@v3
- name: Run lint on notebook's Dockerfile
run: docker run --name hadolint --rm --interactive ${{env.HADOLINT_DOCKER_IMAGE}} < ${{env.DOCKER_FILE}}
ray-lint:
name: ray lint
runs-on: ubuntu-latest

env:
DOCKER_FILE: Dockerfile-ray-qiskit

steps:
- uses: actions/checkout@v3
- name: Run lint on ray's Dockerfile
run: docker run --name hadolint --rm --interactive ${{env.HADOLINT_DOCKER_IMAGE}} < ${{env.DOCKER_FILE}}
repository-lint:
name: repository lint
runs-on: ubuntu-latest

env:
DOCKER_FILE: Dockerfile-repository-server

steps:
- uses: actions/checkout@v3
- name: Run lint on repository's Dockerfile
run: docker run --name hadolint --rm --interactive ${{env.HADOLINT_DOCKER_IMAGE}} < ${{env.DOCKER_FILE}}
17 changes: 9 additions & 8 deletions infrastructure/docker/Dockerfile-gateway
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install psycopg2 dependencies
RUN apt-get -y update \
&& apt-get -y install gcc python3-dev
RUN apt-get -y update &&\
apt-get install --no-install-recommends -y gcc=4:8.3.0-1 python3-dev=3.7.3-1 &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*

USER 0
COPY gateway/requirements.txt .
RUN pip install -r requirements.txt
RUN pip install -r requirements.txt --no-cache-dir
COPY gateway .
RUN chown -R 1000:100 /usr/src/app
RUN mkdir /usr/src/app/media && chown 1000:100 /usr/src/app/media
RUN chown -R 1000:100 /usr/src/app &&\
mkdir /usr/src/app/media && chown 1000:100 /usr/src/app/media

USER 1000:100

RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh &&\
chmod +x /usr/src/app/entrypoint.sh

EXPOSE 8000
# run entrypoint.sh
Expand Down
27 changes: 22 additions & 5 deletions infrastructure/docker/Dockerfile-notebook
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,33 @@ ARG IMAGE_PY_VERSION=3.9
FROM jupyter/base-notebook:python-$IMAGE_PY_VERSION

USER 0
RUN apt-get -y update && apt-get -y install gcc build-essential libopenblas-dev
RUN apt-get -y update &&\
apt-get install --no-install-recommends -y \
gcc=4:11.2.0-1ubuntu1 \
build-essential=12.9ubuntu3 \
libopenblas-dev=0.3.20+ds-1 &&\
apt-get clean &&\
rm -rf /var/lib/apt/lists/*

WORKDIR /
USER $NB_UID

COPY --chown=$NB_UID:$NB_UID ./client ./qs
RUN cd ./qs && pip install .
RUN pip install ipywidgets circuit-knitting-toolbox matplotlib pyscf qiskit-ibmq-provider>=0.20.2 qiskit-aer>=0.12.0
RUN cd ../

WORKDIR /qs
RUN pip install . --no-cache-dir &&\
pip install --no-cache-dir \
ipywidgets==8.0.6 \
circuit-knitting-toolbox==0.2.0 \
matplotlib==3.7.1 \
pyscf==2.2.1 \
qiskit-ibmq-provider==0.20.2 \
qiskit-aer==0.12.0

WORKDIR /
USER 0
RUN rm -r ./qs

USER $NB_UID
COPY --chown=$NB_UID:$NB_UID ./docs/running/notebooks/ ./serverless/running/
COPY --chown=$NB_UID:$NB_UID ./docs/development/examples/ ./serverless/examples/
COPY --chown=$NB_UID:$NB_UID ./docs/development/guides/ ./serverless/guides/
Expand Down
36 changes: 28 additions & 8 deletions infrastructure/docker/Dockerfile-ray-qiskit
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
ARG IMAGE_PY_VERSION=py39

FROM rayproject/ray:2.4.0-$IMAGE_PY_VERSION AS ray-node-amd64

WORKDIR /
USER 0
RUN mkdir /data && chown $RAY_UID:$RAY_UID /data
RUN mkdir /data && chown "$RAY_UID":"$RAY_UID" /data
USER $RAY_UID
COPY --chown=$RAY_UID:$RAY_UID ./client ./qs
RUN cd ./qs && pip install .
RUN cd ../

WORKDIR /qs
RUN pip install . --no-cache-dir

WORKDIR /
RUN rm -r ./qs

FROM rayproject/ray:2.4.0-$IMAGE_PY_VERSION-aarch64 AS ray-node-arm64

WORKDIR /
USER 0
RUN mkdir /data && chown $RAY_UID:$RAY_UID /data
RUN mkdir /data && chown "$RAY_UID":"$RAY_UID" /data
USER $RAY_UID
RUN apt-get -y update && apt-get -y install gcc build-essential libopenblas-dev cmake
RUN apt-get -y update &&\
apt-get install --no-install-recommends -y \
gcc=4:9.3.0-1ubuntu2 \
build-essential=12.8ubuntu1 \
libopenblas-dev=0.3.8+ds-1 \
cmake=3.16.3-1ubuntu1
COPY --chown=$RAY_UID:$RAY_UID ./client ./qs
RUN cd ./qs && pip install .
RUN if [ $TARGETARCH == arm64 ] ; then pip install git+https://github.com/pyscf/pyscf@v2.2.1; fi
RUN cd ../

WORKDIR /qs
RUN pip install . --no-cache-dir &&\
if [ "$TARGETARCH" = "arm64" ] ; \
then pip install --no-cache-dir git+https://github.com/pyscf/pyscf@v2.2.1 ; \
fi

WORKDIR /
USER 0
RUN rm -r ./qs
USER $RAY_UID

# hadolint ignore=DL3006
FROM ray-node-${TARGETARCH} AS final
10 changes: 4 additions & 6 deletions infrastructure/docker/Dockerfile-repository-server
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ ENV PYTHONUNBUFFERED 1

USER 0
COPY repository .
RUN chown -R 1001:0 /usr/src/app

RUN pip install -r requirements.txt
RUN chown -R 1001:0 /usr/src/app &&\
pip install -r requirements.txt --no-cache-dir

USER 1001

RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh
RUN sed -i 's/\r$//g' /usr/src/app/entrypoint.sh &&\
chmod +x /usr/src/app/entrypoint.sh

EXPOSE 8060
# run entrypoint.sh
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]

Loading