Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.
/ alpine-rails-api Public archive

Opinionated Docker image based on Alpine Linux 3.6 that contains the bare minimum to run a GraphQL API server.

Notifications You must be signed in to change notification settings

nater540/alpine-rails-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alpine Rails API

Introduction

Opinionated Docker image based on Alpine Linux 3.6 that contains the bare minimum to run a GraphQL API server.

Note: You must have Packer installed if you want to rebuild the Docker image!

Included packages

Included gems

Updating versions

At the top of the packer.yml file you will see the version numbers specified like so:

variables:
  rails_version: '5.1.4'
  nokogiri_version: '1.8.1'
  cityhash_version: '0.9.0'
  bcrypt_version: '3.1.11'
  graphql_version: '1.1.0'
  oj_version: '3.3.9'
  pg_version: '0.21'

Just fill out the verson numbers that you want installed, and run ./build.rb to rebuild the image. Almost works like magic!

Using the Docker image

  1. Add this to the top of your Dockerfile:
FROM nater540/alpine-rails-api:latest
  1. Copy your application code into /home/app/project_name_goes_here

  2. End your Dockerfile with this:

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisor.conf"]

Ruby Server

This container does NOT include a Ruby server because everyone has their own preference; having said that, I generally perfer to use Puma as my server of choice.

Here is the supervisor config that I use for Puma:

[program:puma]
directory=/home/app/project_name_goes_here
command=/usr/bin/puma -C config/puma.rb
process_name=%(program_name)s
stdout_events_enabled=true
stderr_events_enabled=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stopasgroup=false
killasgroup=false

autorestart=true
autostart=true
startretries=3
startsecs=10

stopsignal=TERM
stopwaitsecs=10
exitcodes=0,2

username=app
priority=999
numprocs=1
umask=022

This file should be copied into /etc/supervisor/conf.d to work properly.

NGINX

Nginx is included and set to startup when the container is brought up.

The default site file is located at /etc/nginx/conf.d/default.conf and is configured to return a 404 Not Found error.

Rebuilding the Docker image

Heads Up

It is strongly recommended that you read this guide first so that you are familiar with creating base images.

Without further ado, here is how you rebuild the base image and publish it!

  1. Install any required gems:
bundle install
  1. Run the following command:
./build.rb

About

Opinionated Docker image based on Alpine Linux 3.6 that contains the bare minimum to run a GraphQL API server.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages