diff options
| author | realtradam <[email protected]> | 2024-06-16 16:21:17 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2024-06-16 16:21:17 -0400 |
| commit | dc387a78548a152d0abea002c8afd86b71e5468a (patch) | |
| tree | a1fbad9c210a7bfe2f20a700fd01f66905fa6e83 | |
| parent | db60994dfa088c44aecfceea6329934b1ce9f3b5 (diff) | |
| download | gameHolster-dc387a78548a152d0abea002c8afd86b71e5468a.tar.gz gameHolster-dc387a78548a152d0abea002c8afd86b71e5468a.zip | |
change docker to build for alpine and postgres
| -rw-r--r-- | Dockerfile | 18 | ||||
| -rw-r--r-- | Gemfile | 2 | ||||
| -rw-r--r-- | Gemfile.lock | 17 | ||||
| -rwxr-xr-x | bin/docker-entrypoint | 2 | ||||
| -rw-r--r-- | docker-compose.yml | 19 |
5 files changed, 34 insertions, 24 deletions
@@ -2,7 +2,8 @@ # Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile ARG RUBY_VERSION=3.2.2 -FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base +#FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base +FROM registry.docker.com/library/ruby:$RUBY_VERSION-alpine3.18 as base # Rails app lives here WORKDIR /rails @@ -18,8 +19,9 @@ ENV RAILS_ENV="production" \ FROM base as build # Install packages needed to build gems -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config +#RUN apt-get update -qq && \ +# apt-get install --no-install-recommends -y build-essential git libpq-dev libvips pkg-config +RUN apk add --update --no-cache build-base git vips postgresql-libs postgresql-dev tzdata # Install application gems COPY Gemfile Gemfile.lock ./ @@ -38,16 +40,18 @@ RUN bundle exec bootsnap precompile app/ lib/ FROM base # Install packages needed for deployment -RUN apt-get update -qq && \ - apt-get install --no-install-recommends -y curl libvips postgresql-client && \ - rm -rf /var/lib/apt/lists /var/cache/apt/archives +#RUN apt-get update -qq && \ +# apt-get install --no-install-recommends -y curl libvips postgresql-client && \ +# rm -rf /var/lib/apt/lists /var/cache/apt/archives +RUN apk add --update --no-cache curl vips postgresql-client # Copy built artifacts: gems, application COPY --from=build /usr/local/bundle /usr/local/bundle COPY --from=build /rails /rails # Run and own only the runtime files as a non-root user for security -RUN useradd rails --create-home --shell /bin/bash && \ +#RUN useradd rails --create-home --shell /bin/bash && \ +RUN adduser rails --disabled-password --shell /bin/ash && \ chown -R rails:rails db log storage tmp USER rails:rails @@ -24,7 +24,7 @@ gem "puma", ">= 5.0" gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] +gem "tzinfo-data"#, platforms: %i[ windows jruby ] # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false diff --git a/Gemfile.lock b/Gemfile.lock index f163f71..cf57930 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -121,16 +121,6 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.3) - nokogiri (1.16.5-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.5-arm-linux) - racc (~> 1.4) - nokogiri (1.16.5-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.5-x86-linux) - racc (~> 1.4) - nokogiri (1.16.5-x86_64-darwin) - racc (~> 1.4) nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) pg (1.5.6) @@ -189,6 +179,8 @@ GEM timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + tzinfo-data (1.2024.1) + tzinfo (>= 1.0.0) webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -196,11 +188,6 @@ GEM zeitwerk (2.6.14) PLATFORMS - aarch64-linux - arm-linux - arm64-darwin - x86-linux - x86_64-darwin x86_64-linux DEPENDENCIES diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint index 67ef493..fe91345 100755 --- a/bin/docker-entrypoint +++ b/bin/docker-entrypoint @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/ash -e # If running the rails server then create or migrate existing database if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..67167d4 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +# docker-compose.yml +services: + app: + build: . + stdin_open: true + tty: true + platform: linux/amd64 + environment: + - RAILS_ENV=development + ports: + - 3000:3000 + volumes: + - .:/rails + command: ["bin/rails", "server", "-b", "0.0.0.0"] + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3000/healthz"] + interval: 30s + timeout: 10s + retries: 5 |
