schneidmaster / gitreports.com

Git Reports is a free service that lets you set up a stable URL for anonymous users to submit bugs and other Issues to your GitHub repositories.
MIT License
134 stars 26 forks source link

Dockerize gitreports.com #150

Closed johndmulhausen closed 2 years ago

johndmulhausen commented 4 years ago

Trying to Dockerize gitreports.com to make it easy to self-host

To run:

docker build -t testgit .

Then you can run:

docker run -ti -p 5000:5000 -p 3808:3808 testgit

And the service will be available at http://localhost:5000

schneidmaster commented 4 years ago

Hi, thanks for the PR! A couple of thoughts on this:

  1. Currently the Dockerfile is running the webpack development server over port 3808 which is not ideal if the goal is self-hosting in production (it would be more appropriate if this were a Dockerfile for use in development). Instead you can add a RUN TARGET=production npm run build after the yarn install line, and then make sure the RAILS_ENV var is set to production so that Rails looks for the prebuilt assets rather than the dev server. And then you don't need to expose port 3808 or have the host stuff.

  2. How does this work with postgres? Currently the app tries to connect to postgres via the connection string in the DATABASE_URL env variable which doesn't seem like it would work here.

johndmulhausen commented 4 years ago

@schneidmaster Tried to make these changes but it just ceases to run. Perhaps you can try to help?

FROM ruby:2.4.5

# Install redis, sudo, nodejs, postgresql, and yarn
# redis & sudo
RUN apt-get update && apt-get -y install redis-server sudo
# node
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN sudo apt-get install -y nodejs
# postgresql
RUN sudo apt-get -y install wget ca-certificates
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RUN sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
RUN sudo apt-get update
RUN sudo apt-get -y install postgresql postgresql-contrib
# yarn
RUN npm install -g yarn

# Set ENV vars
ENV RAILS_ENV production
ENV TARGET production
ENV DATABASE_URL postgresql://localhost

# Set up working dir
RUN mkdir /app
WORKDIR /app
COPY . /app/

# Install app dependencies
RUN gem install foreman
RUN bundle install -j 8
RUN yarn install

# Run build
RUN npm run build

# Expose port 5000 from within the container to the world
EXPOSE 5000

# Start the Rails and webpack servers
CMD service postgresql start && redis-server --daemonize yes && bundle exec rails db:migrate && foreman start -f Procfile.dev

It just dies when running:

rails aborted!
URI::InvalidURIError: bad URI(is not URI?): 
/usr/local/bundle/gems/sentry-raven-2.6.0/lib/raven/configuration.rb:212:in `server='
schneidmaster commented 4 years ago

Sorry for the delay. I think the issue is this line:

https://github.com/schneidmaster/gitreports.com/blob/3e38bb9794260a7364982c62935faf2b50fe2b1a/config/initializers/sentry.rb#L1-L5

which initializes Sentry for error reporting in production. That can likely be fixed by changing the conditional on the first line to if Rails.env.production? && ENV['SENTRY_DSN'], i.e. don't try to initialize Sentry if there's no SENTRY_DSN env var set.