Sage-Bionetworks / research-benchmarking-technology

Main repository of the Research & Benchmarking Technology Team
Apache License 2.0
1 stars 1 forks source link

Fix new Hadolint warning DL3045 #11

Closed tschaffter closed 3 years ago

tschaffter commented 3 years ago

This new warning makes the lint job of most of our repositories fail. The warning is described here.

tschaffter commented 3 years ago

Example of the current code from the Date Annotator Example. This code should meet the best practice defined by DL3045 (APP_DIR an absolute path). My guess is that the linter fails because I used a variable while it's looking for a string that starts with /....

ENV APP_DIR=/opt/app

COPY openapi_server ${APP_DIR}/openapi_server
COPY requirements.txt uwsgi.ini ${APP_DIR}/
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh

Mu current preferred solution is:

ENV APP_DIR=/opt/app

WORKDIR ${APP_DIR}
COPY openapi_server openapi_server/
COPY requirements.txt prod-requirements.txt uwsgi.ini ./
RUN pip install --no-cache-dir \
    -r requirements.txt -r prod-requirements.txt

WORKDIR /
COPY docker-entrypoint.sh .
RUN chmod +x docker-entrypoint.sh

Notes:

thomasyu888 commented 3 years ago

+1 for your current preferred solution. I didn't reallize you could do pip install requirements.txt without the -r

tschaffter commented 3 years ago

I didn't reallize you could do pip install requirements.txt without the -r

It's actually a typo. I updated the proposed solution to reflect this typo.

tschaffter commented 3 years ago

I updated the Dockerfiles of the NLP Sandbox and ROCC.