Skip to content

Commit

Permalink
Merge pull request #1223 from dradis/kamal
Browse files Browse the repository at this point in the history
Dockerize the repo
  • Loading branch information
etdsoft committed Feb 7, 2024
2 parents 5c02515 + 6fc9720 commit e1e0493
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 106 deletions.
36 changes: 36 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# Ignore git directory.
/.git

# Ignore bundle config.
/.bundle

# Ignore environment and deployment files.
/.env*
/.kamal/*
/config/deploy.yml

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles.
/tmp/pids/*
!/tmp/pids/.keep

# Ignore storage.
/storage/*
!/storage/.keep
/tmp/storage/*
!/tmp/storage/.keep

# Ignore assets.
/public/assets

# Ignore applicaiton folders
/attachments/
/config/shared/*
/db/*.sqlite3
/templates/*
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
# RSpec testing
/spec/.examples.txt

# Ignore environment and deployment files
/.env*
/.kamal/*
/config/deploy.yml

# App-specific
/attachments/
/backup/
Expand Down
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# We're sticking to non-slim version: https://hub.docker.com/_/ruby/
FROM --platform=amd64 ruby:3.1.2

WORKDIR /app

# Copying dradis-ce app
COPY . .

# Copying sample files
COPY config/database.yml.template config/database.yml
COPY config/smtp.yml.template config/smtp.yml

# Preparing application folders
RUN mkdir -p attachments/
RUN mkdir -p config/shared/
RUN mkdir -p templates/

# Is this only needed because M1 build?
RUN bundle config build.ffi --enable-libffi-alloc

# Installing dependencies
RUN bundle install

# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
chown -R rails:rails attachments config/shared db log tmp templates
USER rails:rails

# Preparing database
RUN bin/rails db:prepare
#RUN bin/rails db:seed

# Entrypoint prepares the database.
# ENTRYPOINT ["/app/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
# CMD ["./bin/rails", "server"]
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]
25 changes: 7 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,18 @@ There are two editions of Dradis Framework:

[Installing Dradis from Git](https://dradis.com/ce/documentation/install_git.html)

### Using Vagrant
### Using Docker

If you'd like to use dradis in Vagrant, you can use the included Vagrantfile.
If you'd like to use Dradis in Docker, first get the latest image:

```
# Clone the repo
git clone https://github.com/dradis/dradis-ce.git
cd dradis-ce/
# install/start the vagrant box
vagrant up
# ssh into the box
vagrant ssh
# install ruby in the vagrant box
cd /dradis/dradis-ce
rvm install "$(cat .ruby-version)"
docker image pull dradis/dradis-ce:latest
```

And then run the container:

# Then you can proceed with standard setup from within Vagrant
ruby bin/setup
# You'll need to tell the server to bind to 0.0.0.0 for port forwarding:
bundle exec rails server -b 0.0.0.0
```
docker run -it -p 3000:3000 dradis/dradis-ce
```


Expand Down
88 changes: 0 additions & 88 deletions Vagrantfile

This file was deleted.

2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
end

Rails.application.routes.draw do
get 'up', to: ->(env) { [204, {}, ['']] }

# ------------------------------------------------------------ Authentication
# Sign in / sign out
get '/login' => 'sessions#new'
Expand Down

0 comments on commit e1e0493

Please sign in to comment.