Skip to content

Entrypoints #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
# syntax=docker/dockerfile:1

ARG RUBY_VERSION=3.3
FROM ruby:${RUBY_VERSION}-alpine

RUN apk add --no-cache --update \
build-base \
postgresql-client \
postgresql-dev \
tzdata
git \
tzdata \
vim bash

# Set up entrypoint
WORKDIR /
COPY entrypoint.sh .
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

# Set up bundle path
COPY docker-entrypoint.sh .
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
WORKDIR /docker-entrypoint.d
COPY docker-entrypoint.d/10-remove-pid.sh .
COPY docker-entrypoint.d/20-database-url.sh .
COPY docker-entrypoint.d/30-bundle-install.sh .
RUN chmod +x /docker-entrypoint.d/*.sh

# Set up bundler
RUN mkdir -p /usr/local/bundle
ENV BUNDLE_PATH /usr/local/bundle
ENV BUNDLE_PATH=/usr/local/bundle
RUN gem install bundler || gem install bundler -v 2.4.22 # This fallback supports older versions of ruby/bundler

# Set up pid file
RUN mkdir -p /var/run/
ENV PIDFILE /var/run/puma.pid
ENV PIDFILE=/var/run/puma.pid

# Configure default environment setup
WORKDIR /app
ENV RAILS_ENV production
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_LOG_TO_STDOUT=true

ENV BINDING 0.0.0.0
ENV PORT 80
ENV BINDING=0.0.0.0
ENV PORT=80
EXPOSE 80

CMD ["bundle", "exec", "rails", "server"]
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
RUBY_VERSIONS_FILE := ruby_versions.txt

.PHONY: build
build:
docker buildx bake
@while IFS= read -r version; do \
echo "Building for Ruby $$version..."; \
RUBY_VERSION=$$version docker buildx bake; \
done < $(RUBY_VERSIONS_FILE)

push:
docker buildx bake --push
@while IFS= read -r version; do \
echo "Building and pushing for Ruby $$version..."; \
RUBY_VERSION=$$version docker buildx bake --push; \
done < $(RUBY_VERSIONS_FILE)
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,23 @@ This image is very opinionated; however, not restrictive.

### Ruby 3.3
- [ruby3.3, ruby3, latest](Dockerfile)
- [ruby3.3-local, ruby3-local, local](local.Dockerfile)
- [ruby3.3-webapp, ruby3-webapp, webapp](webapp/Dockerfile)
- [ruby3.3-webapp-local, ruby3-webapp-local, webapp-local](webapp/local.Dockerfile)

### Ruby 3.2
- [ruby3.2](Dockerfile)
- [ruby3.2-local](local.Dockerfile)
- [ruby3.2-webapp](webapp/Dockerfile)
- [ruby3.2-webapp-local](webapp/local.Dockerfile)
-
### Ruby 3.1
- [ruby3.1](Dockerfile)
- [ruby3.1-local](local.Dockerfile)
- [ruby3.1-webapp](webapp/Dockerfile)
- [ruby3.1-webapp-local](webapp/local.Dockerfile)

### Ruby 3.0
- [ruby3.0](Dockerfile)
- [ruby3.0-local](local.Dockerfile)
- [ruby3.0-webapp](webapp/Dockerfile)
- [ruby3.0-webapp-local](webapp/local.Dockerfile)

### Ruby 2.7
- [ruby2.7](Dockerfile)
- [ruby2.7-local](local.Dockerfile)
- [ruby2.7-webapp](webapp/Dockerfile)
- [ruby2.7-webapp-local](webapp/local.Dockerfile)

## Production vs Local

Expand Down
261 changes: 10 additions & 251 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -1,264 +1,23 @@
group "default" {
targets = [
"ruby3-3",
"ruby3-3-local",
"ruby3-3-webapp",
"ruby3-3-webapp-local",

"ruby3-2",
"ruby3-2-local",
"ruby3-2-webapp",
"ruby3-2-webapp-local",

"ruby3-1",
"ruby3-1-local",
"ruby3-1-webapp",
"ruby3-1-webapp-local",

"ruby3-0",
"ruby3-0-local",
"ruby3-0-webapp",
"ruby3-0-webapp-local",

"ruby2-7",
"ruby2-7-local",
"ruby2-7-webapp",
"ruby2-7-webapp-local",
]
}

target "ruby3-3" {
dockerfile = "Dockerfile"
tags = [
"nullstone/rails:ruby3.3",
"nullstone/rails:ruby3",
"nullstone/rails",
]
args = {
"RUBY_VERSION" = "3.3"
}
}

target "ruby3-3-local" {
dockerfile = "local.Dockerfile"
tags = [
"nullstone/rails:ruby3.3-local",
"nullstone/rails:ruby3-local",
"nullstone/rails:local",
]
args = {
"RUBY_VERSION" = "3.3"
}
}

target "ruby3-3-webapp" {
dockerfile = "webapp/Dockerfile"
tags = [
"nullstone/rails:ruby3.3-webapp",
"nullstone/rails:ruby3-webapp",
"nullstone/rails:webapp"
]
args = {
"RUBY_VERSION" = "3.3"
}
}

target "ruby3-3-webapp-local" {
dockerfile = "webapp/local.Dockerfile"
tags = [
"nullstone/rails:ruby3.3-webapp-local",
"nullstone/rails:ruby3-webapp-local",
"nullstone/rails:webapp-local"
]
args = {
"RUBY_VERSION" = "3.3"
}
}

group "group-ruby3-2" {
targets = [
"ruby3-2",
"ruby3-2-local",
"ruby3-2-webapp",
"ruby3-2-webapp-local",
]
}

target "ruby3-2" {
dockerfile = "Dockerfile"
tags = ["nullstone/rails:ruby3.2"]
args = {
"RUBY_VERSION" = "3.2.2"
}
}

target "ruby3-2-local" {
dockerfile = "local.Dockerfile"
tags = ["nullstone/rails:ruby3.2-local"]
args = {
"RUBY_VERSION" = "3.2.2"
}
}

target "ruby3-2-webapp" {
dockerfile = "webapp/Dockerfile"
tags = ["nullstone/rails:ruby3.2-webapp"]
args = {
"RUBY_VERSION" = "3.2.2"
}
}

target "ruby3-2-webapp-local" {
dockerfile = "webapp/local.Dockerfile"
tags = ["nullstone/rails:ruby3.2-webapp-local"]
args = {
"RUBY_VERSION" = "3.2.2"
}
}

group "group-ruby3-1" {
targets = [
"ruby3-1",
"ruby3-1-local",
"ruby3-1-webapp",
"ruby3-1-webapp-local",
]
}

target "ruby3-1" {
dockerfile = "Dockerfile"
tags = [
"nullstone/rails:ruby3.1",
]
args = {
"RUBY_VERSION" = "3.1"
}
}

target "ruby3-1-local" {
dockerfile = "local.Dockerfile"
tags = [
"nullstone/rails:ruby3.1-local",
]
args = {
"RUBY_VERSION" = "3.1"
}
}

target "ruby3-1-webapp" {
dockerfile = "webapp/Dockerfile"
tags = [
"nullstone/rails:ruby3.1-webapp",
]
args = {
"RUBY_VERSION" = "3.1"
}
}

target "ruby3-1-webapp-local" {
dockerfile = "webapp/local.Dockerfile"
tags = [
"nullstone/rails:ruby3.1-webapp-local",
]
args = {
"RUBY_VERSION" = "3.1"
}
}

group "group-ruby3-0" {
targets = [
"ruby3-0",
"ruby3-0-local",
"ruby3-0-webapp",
"ruby3-0-webapp-local",
]
}

target "ruby3-0" {
dockerfile = "Dockerfile"
tags = [
"nullstone/rails:ruby3.0"
]
args = {
"RUBY_VERSION" = "3.0"
}
variable "RUBY_VERSION" {
default = "3.4"
}

target "ruby3-0-local" {
dockerfile = "local.Dockerfile"
tags = [
"nullstone/rails:ruby3.0-local"
]
args = {
"RUBY_VERSION" = "3.0"
}
}

target "ruby3-0-webapp" {
dockerfile = "webapp/Dockerfile"
tags = [
"nullstone/rails:ruby3.0-webapp"
]
args = {
"RUBY_VERSION" = "3.0"
}
}

target "ruby3-0-webapp-local" {
dockerfile = "webapp/local.Dockerfile"
tags = [
"nullstone/rails:ruby3.0-webapp-local"
]
args = {
"RUBY_VERSION" = "3.0"
}
}

group "group-ruby2-7" {
targets = [
"ruby2-7",
"ruby2-7-local",
"ruby2-7-webapp",
"ruby2-7-webapp-local",
]
group "default" {
targets = ["normal", "webapp"]
}

target "ruby2-7" {
target "normal" {
dockerfile = "Dockerfile"
tags = [
"nullstone/rails:ruby2.7"
]
tags = ["nullstone/rails:ruby${RUBY_VERSION}"]
args = {
"RUBY_VERSION" = "2.7"
RUBY_VERSION = RUBY_VERSION
}
}

target "ruby2-7-local" {
dockerfile = "local.Dockerfile"
tags = [
"nullstone/rails:ruby2.7-local"
]
args = {
"RUBY_VERSION" = "2.7"
}
}

target "ruby2-7-webapp" {
target "webapp" {
dockerfile = "webapp/Dockerfile"
tags = [
"nullstone/rails:ruby2.7-webapp"
]
args = {
"RUBY_VERSION" = "2.7"
}
}

target "ruby2-7-webapp-local" {
dockerfile = "webapp/local.Dockerfile"
tags = [
"nullstone/rails:ruby2.7-webapp-local"
]
tags = ["nullstone/rails:ruby${RUBY_VERSION}-webapp"]
args = {
"RUBY_VERSION" = "2.7"
RUBY_VERSION = RUBY_VERSION
}
}
6 changes: 6 additions & 0 deletions docker-entrypoint.d/10-remove-pid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -e

echo "Removing pid file"
rm -f "${PIDFILE}"
Loading