dradis / dradis-ce

Dradis Framework: Collaboration and reporting for IT Security teams
https://dradis.com/ce/
GNU General Public License v2.0
672 stars 190 forks source link

Docker build and push to github container registry #1091

Open floriandulzky opened 1 year ago

floriandulzky commented 1 year ago

Expected behavior

A github action that creates a docker image and push it automatically to the github container registry (ghcr.io) See fork: https://github.com/dradis/dradis-ce/compare/develop...floriandulzky:dradis-ce:feature/docker-build

Did not create a PR yet. Will update the documentation and then make the PR. But I want to make sure this "feature" is in your interest?

PeterBennink commented 1 year ago

This could be improved further like this:

FROM ruby:3.1.2-slim

ARG APT="-y --no-install-recommends --no-upgrade -o Dpkg::Options::=--force-confnew"

COPY . .
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install $APT build-essential libpq-dev libsqlite3-dev git && \
    ./bin/setup skip-server && \
    # clean image
    DEBIAN_FRONTEND=noninteractive apt $APT remove build-essential gcc libmariadbd-dev libsqlite3-dev make patch wget zlib1g-dev && \
    DEBIAN_FRONTEND=noninteractive apt install $APT libmariadb3 libsqlite3-0 zlib1g && \
    DEBIAN_FRONTEND=noninteractive apt autoremove -y && \
    rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* && \
    rm -rf /data/development.sqlite3 && \
    rm -rf /vendor/bundle/ruby/3.1.0/cache /usr/local/bundle/cache

CMD ["ruby", "bin/rails", "server", "-b", "0.0.0.0"]

This reduces the image size from 1.5GB to 850MB.

etdsoft commented 7 months ago

We've made some progress and added a https://github.com/dradis/dradis-ce/blob/develop/Dockerfile any thoughts?

floriandulzky commented 7 months ago

We've made some progress and added a https://github.com/dradis/dradis-ce/blob/develop/Dockerfile any thoughts?

I think you also could use FROM ruby:3.1.2-slim (untested) like @PeterBennink suggested.