Docker container for Ahoy web analytics tracking. See: https://github.com/ankane/ahoy
610
Docker container for Ahoy web analytics tracking. See: https://github.com/ankane/ahoy
Source files for a Ruby Docker image pre-built with dependencies for Rails + MySql client (does not include the db server).
image repo: https://hub.docker.com/r/floatapp/ahoy-api/
docker pull floatapp/ahoy-api:latest
Copy the repo files to a directory on your Docker host and run:
docker-compose up
If all goes well, you should be able to navigate to http://localhost:3000 or similar and see the app working with the linked MySql (MariaDB) db container. Phpmyadmin container is mapped to http://localhost:3080 to check the data. Note: on first-run, the MySql database may not build in time to sync to the Rails app. If this happens, simply restart via:
docker-compose restart
See the Ahoy docs for how to run the db migration, if using the provided docker-compose file in this repo and you get the Rails success page, you should be able to create the Ahoy tables via:
docker-compose run web rake db:migrate RAILS_ENV=developmentIf needed, restart the web app via:
docker-compose restart webSince this is an api-optimized app, you would generally use the Ahoy.js library and proxy to the ahoy/visits and ahoy/events endpoints. See: https://github.com/ankane/ahoy.js for info on Ahoy. See http://edgeguides.rubyonrails.org/api_app.html for more info on Rails in API-only mode. Except for the "Yay! You’re on Rails!" default homepage, which you should probably change, responses will be in JSON.
To use just the image and not the files in this repo, see below
docker pull floatapp/ahoy-api:latest
The Docker image contains api-optimized Rails app Gemfile located in the /ahoy directory. The source files and libs have been pre-built but you can extract the application files, preferably in an external volume. The db and environment-specific configuration files will need to be set as appropriate.
cd to an empty local directorydocker run --rm -v $(pwd)/:/tmp floatapp/ahoy-api:latest bash -c "cp -r /ahoy/* /tmp"
This will extract the app files to your locally mounted directory. Update the config files as needed (particularly config/database.yml). Then you can run by mounting the local directory and starting the rails server:
docker run --name=ahoy -v $(pwd)/:/ahoy -p 3000:3000 floatapp/ahoy-api:latest bundle exec rails s -p 3000 -b '0.0.0.0'
If you see output that has * Listening on tcp://0.0.0.0:3000 near the end, you should be good. Navigate to: http://localhost:3000/ (or whatever your dockerhost is) to try it out. Change the inside and outside ports as desired.
Using docker run or exec, install the models rails generate ahoy:stores:active_record and run the db migration, rake db:migrate RAILS_ENV=development. Restart the container to restart the web app if needed.
If you didn't configure your database (properly), you'll see some error response to that effect. Otherwise, the index page should show a success message and the /ahoy/visits and /ahoy/events POST routes should work (see the Ahoy docs). Note if you kept the api-optimized settings, the responses will be in JSON. You can change the config as needed, but for a full web app, you'll most likely need a different Gemfile. You can use this image with docker-compose (see docker-compose.yml file), and that would generally be easier for most environments especially if you wanted to add a database and proxy server, etc.
Note this image is designed for a development sandbox. You would want to make some updates for a production environment and adjust the configuration (and start command) as needed.
Content type
Image
Digest
Size
322.6 MB
Last updated
over 9 years ago
docker pull floatapp/ahoy-api