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

Lint Dockerfiles #3663

Merged
merged 14 commits into from
Mar 18, 2021
8 changes: 8 additions & 0 deletions .github/workflows/docker-image-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ jobs:
- name: Checkout PR branch
uses: actions/checkout@v2

- name: Lint Dockerfiles with Hadolint
run: |
# Install latest Hadolint binary from GitHub (not available via apt)
HADOLINT_LATEST_TAG=$(curl --silent "https://api.github.com/repos/hadolint/hadolint/releases/latest" | jq -r .tag_name)
sudo curl -sLo /usr/bin/hadolint "https://github.com/hadolint/hadolint/releases/download/$HADOLINT_LATEST_TAG/hadolint-Linux-x86_64"
sudo chmod +x /usr/bin/hadolint
hadolint **Dockerfile

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand Down
14 changes: 8 additions & 6 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update \
&& apt-get install -y --no-install-recommends curl git build-essential \
&& apt-get install -y --no-install-recommends curl=7.64.0-4+deb10u1 git=1:2.20.1-2+deb10u3 build-essential=12.6 \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& apt-get install -y --no-install-recommends nodejs=14.16.0-1nodesource1 \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g yarn@1 \
&& yarn config set network-timeout 300000 \
&& yarn --frozen-lockfile

COPY requirements.txt /code/
COPY requirements-dev.txt /code/
# install dependencies but ignore any we don't need for dev environment
RUN pip install $(grep -ivE "psycopg2" requirements.txt | cut -d'#' -f1) --compile\
&& pip install psycopg2-binary
RUN pip install -r requirements.txt --no-cache-dir

# install dev dependencies
RUN mkdir /code/requirements/
COPY requirements-dev.txt /code/requirements/
RUN pip install -r requirements-dev.txt --compile
RUN pip install -r requirements-dev.txt --compile --no-cache-dir

COPY package.json /code/
COPY yarn.lock /code/
Expand All @@ -44,6 +46,6 @@ RUN DEBUG=1 DATABASE_URL='postgres:///' REDIS_URL='redis:///' python manage.py c
EXPOSE 8000
EXPOSE 8234
RUN yarn install
RUN cd plugins && yarn install
RUN yarn install --cwd plugins
ENV DEBUG 1
CMD ["./bin/docker-dev"]
72 changes: 0 additions & 72 deletions preview.Dockerfile

This file was deleted.

20 changes: 10 additions & 10 deletions production.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ WORKDIR /code

COPY . /code/

RUN apt-get update && apt-get install -y --no-install-recommends curl git build-essential \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install nodejs -y --no-install-recommends \
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get update \
&& apt-get install -y --no-install-recommends curl=7.64.0-4+deb10u1 git=1:2.20.1-2+deb10u3 build-essential=12.6 \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get install -y --no-install-recommends nodejs=14.16.0-1nodesource1 \
&& npm install -g yarn@1 \
&& yarn config set network-timeout 300000 \
&& yarn --frozen-lockfile \
&& yarn build \
&& cd plugins \
&& yarn --frozen-lockfile --ignore-optional \
&& cd .. \
&& yarn --cwd plugins --frozen-lockfile --ignore-optional \
&& yarn cache clean \
&& apt-get purge -y curl build-essential \
&& rm -rf node_modules \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf node_modules

# install dependencies but ignore any we don't need for dev environment
RUN pip install $(grep -ivE "psycopg2" requirements.txt | cut -d'#' -f1) --no-cache-dir --compile\
&& pip install psycopg2-binary --no-cache-dir --compile\
RUN pip install -r requirements.txt --no-cache-dir --compile \
&& pip uninstall ipython-genutils pip -y

RUN SECRET_KEY='unsafe secret key for collectstatic only' DATABASE_URL='postgres:///' REDIS_URL='redis:///' python manage.py collectstatic --noinput
Expand Down