mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-03 15:30:59 +00:00
add dockerfile for ror, fix template issue (#718)
This commit is contained in:
parent
f0425d77ef
commit
f32398a708
@ -122,7 +122,7 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
|||||||
additionalProperties.put("isDBSQLite", Boolean.TRUE);
|
additionalProperties.put("isDBSQLite", Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
supportingFiles.add(new SupportingFile("Gemfile", "", "Gemfile"));
|
supportingFiles.add(new SupportingFile("Gemfile.mustache", "", "Gemfile"));
|
||||||
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.md", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("Rakefile", "", "Rakefile"));
|
supportingFiles.add(new SupportingFile("Rakefile", "", "Rakefile"));
|
||||||
supportingFiles.add(new SupportingFile("config.ru", "", "config.ru"));
|
supportingFiles.add(new SupportingFile("config.ru", "", "config.ru"));
|
||||||
@ -155,7 +155,7 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
|||||||
supportingFiles.add(new SupportingFile("application.rb", configFolder, "application.rb"));
|
supportingFiles.add(new SupportingFile("application.rb", configFolder, "application.rb"));
|
||||||
supportingFiles.add(new SupportingFile("boot.rb", configFolder, "boot.rb"));
|
supportingFiles.add(new SupportingFile("boot.rb", configFolder, "boot.rb"));
|
||||||
supportingFiles.add(new SupportingFile("cable.yml", configFolder, "cable.yml"));
|
supportingFiles.add(new SupportingFile("cable.yml", configFolder, "cable.yml"));
|
||||||
supportingFiles.add(new SupportingFile("database.yml", configFolder, "database.yml"));
|
supportingFiles.add(new SupportingFile("database.mustache", configFolder, "database.yml"));
|
||||||
supportingFiles.add(new SupportingFile("environment.rb", configFolder, "environment.rb"));
|
supportingFiles.add(new SupportingFile("environment.rb", configFolder, "environment.rb"));
|
||||||
supportingFiles.add(new SupportingFile("puma.rb", configFolder, "puma.rb"));
|
supportingFiles.add(new SupportingFile("puma.rb", configFolder, "puma.rb"));
|
||||||
supportingFiles.add(new SupportingFile("routes.mustache", configFolder, "routes.rb"));
|
supportingFiles.add(new SupportingFile("routes.mustache", configFolder, "routes.rb"));
|
||||||
@ -181,6 +181,8 @@ public class RubyOnRailsServerCodegen extends AbstractRubyCodegen {
|
|||||||
supportingFiles.add(new SupportingFile(".keep", socketsFolder, ".keep"));
|
supportingFiles.add(new SupportingFile(".keep", socketsFolder, ".keep"));
|
||||||
supportingFiles.add(new SupportingFile("restart.txt", tmpFolder, "restart.txt"));
|
supportingFiles.add(new SupportingFile("restart.txt", tmpFolder, "restart.txt"));
|
||||||
supportingFiles.add(new SupportingFile(".keep", vendorFolder, ".keep"));
|
supportingFiles.add(new SupportingFile(".keep", vendorFolder, ".keep"));
|
||||||
|
supportingFiles.add(new SupportingFile("Dockerfile", "", "Dockerfile"));
|
||||||
|
supportingFiles.add(new SupportingFile("docker-entrypoint.sh", "", "docker-entrypoint.sh"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
FROM ruby:2.5-alpine
|
||||||
|
|
||||||
|
ENV BUILD_PACKAGES="curl-dev ruby-dev build-base" \
|
||||||
|
DEV_PACKAGES="zlib-dev libxml2-dev libxslt-dev tzdata yaml-dev sqlite-dev" \
|
||||||
|
RUBY_PACKAGES="ruby-json yaml nodejs"
|
||||||
|
|
||||||
|
RUN apk update && \
|
||||||
|
apk upgrade && \
|
||||||
|
apk add --no-cache --update\
|
||||||
|
$BUILD_PACKAGES \
|
||||||
|
$DEV_PACKAGES \
|
||||||
|
$RUBY_PACKAGES && \
|
||||||
|
mkdir -p /usr/src/myapp
|
||||||
|
|
||||||
|
WORKDIR /usr/src/myapp
|
||||||
|
|
||||||
|
COPY Gemfile ./
|
||||||
|
RUN gem install bundler
|
||||||
|
RUN bundle config build.nokogiri --use-system-libraries && \
|
||||||
|
bundle install --jobs=4 --retry=10 --clean
|
||||||
|
|
||||||
|
COPY . ./
|
||||||
|
RUN chmod +x bin/rails
|
||||||
|
|
||||||
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD ["bin/rails", "s", "-b", "0.0.0.0"]
|
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = 'bin/rails' ] && [ "$2" = 's' ]; then
|
||||||
|
rm -f /myapp/tmp/pids/server.pid
|
||||||
|
bin/rails db:migrate
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
29
samples/server/petstore/ruby-on-rails/Dockerfile
Normal file
29
samples/server/petstore/ruby-on-rails/Dockerfile
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
FROM ruby:2.5-alpine
|
||||||
|
|
||||||
|
ENV BUILD_PACKAGES="curl-dev ruby-dev build-base" \
|
||||||
|
DEV_PACKAGES="zlib-dev libxml2-dev libxslt-dev tzdata yaml-dev sqlite-dev" \
|
||||||
|
RUBY_PACKAGES="ruby-json yaml nodejs"
|
||||||
|
|
||||||
|
RUN apk update && \
|
||||||
|
apk upgrade && \
|
||||||
|
apk add --no-cache --update\
|
||||||
|
$BUILD_PACKAGES \
|
||||||
|
$DEV_PACKAGES \
|
||||||
|
$RUBY_PACKAGES && \
|
||||||
|
mkdir -p /usr/src/myapp
|
||||||
|
|
||||||
|
WORKDIR /usr/src/myapp
|
||||||
|
|
||||||
|
COPY Gemfile ./
|
||||||
|
RUN gem install bundler
|
||||||
|
RUN bundle config build.nokogiri --use-system-libraries && \
|
||||||
|
bundle install --jobs=4 --retry=10 --clean
|
||||||
|
|
||||||
|
COPY . ./
|
||||||
|
RUN chmod +x bin/rails
|
||||||
|
|
||||||
|
COPY docker-entrypoint.sh /usr/local/bin/
|
||||||
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||||
|
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD ["bin/rails", "s", "-b", "0.0.0.0"]
|
@ -3,14 +3,8 @@ source 'https://rubygems.org'
|
|||||||
|
|
||||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||||
gem 'rails', '~> 5.0.0'
|
gem 'rails', '~> 5.0.0'
|
||||||
{{#isDBSQLite}}
|
|
||||||
# Use sqlite as the database for Active Record
|
# Use sqlite as the database for Active Record
|
||||||
gem 'sqlite3', '~> 1.3'
|
gem 'sqlite3', '~> 1.3'
|
||||||
{{/isDBSQLite}}
|
|
||||||
{{#isDBMySQL}}
|
|
||||||
# Use mysql as the database for Active Record
|
|
||||||
gem 'mysql2', '>= 0.3.18', '< 0.5'
|
|
||||||
{{/isDBMySQL}}
|
|
||||||
# Use Puma as the app server
|
# Use Puma as the app server
|
||||||
gem 'puma', '~> 3.0'
|
gem 'puma', '~> 3.0'
|
||||||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
||||||
|
@ -1,60 +1,3 @@
|
|||||||
{{#isDBMySQL}}
|
|
||||||
# MySQL. Versions 5.0 and up are supported.
|
|
||||||
#
|
|
||||||
# Install the MySQL driver
|
|
||||||
# gem install mysql2
|
|
||||||
#
|
|
||||||
# Ensure the MySQL gem is defined in your Gemfile
|
|
||||||
# gem 'mysql2'
|
|
||||||
#
|
|
||||||
# And be sure to use new-style password hashing:
|
|
||||||
# http://dev.mysql.com/doc/refman/5.7/en/old-client.html
|
|
||||||
#
|
|
||||||
default: &default
|
|
||||||
adapter: mysql2
|
|
||||||
encoding: utf8
|
|
||||||
pool: 5
|
|
||||||
username: root
|
|
||||||
password:
|
|
||||||
socket: /tmp/mysql.sock
|
|
||||||
|
|
||||||
development:
|
|
||||||
<<: *default
|
|
||||||
database: api_demo_development
|
|
||||||
|
|
||||||
# Warning: The database defined as "test" will be erased and
|
|
||||||
# re-generated from your development database when you run "rake".
|
|
||||||
# Do not set this db to the same as development or production.
|
|
||||||
test:
|
|
||||||
<<: *default
|
|
||||||
database: api_demo_test
|
|
||||||
|
|
||||||
# As with config/secrets.yml, you never want to store sensitive information,
|
|
||||||
# like your database password, in your source code. If your source code is
|
|
||||||
# ever seen by anyone, they now have access to your database.
|
|
||||||
#
|
|
||||||
# Instead, provide the password as a unix environment variable when you boot
|
|
||||||
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
|
|
||||||
# for a full rundown on how to provide these environment variables in a
|
|
||||||
# production deployment.
|
|
||||||
#
|
|
||||||
# On Heroku and other platform providers, you may have a full connection URL
|
|
||||||
# available as an environment variable. For example:
|
|
||||||
#
|
|
||||||
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
|
|
||||||
#
|
|
||||||
# You can use this database configuration with:
|
|
||||||
#
|
|
||||||
# production:
|
|
||||||
# url: <%= ENV['DATABASE_URL'] %>
|
|
||||||
#
|
|
||||||
production:
|
|
||||||
<<: *default
|
|
||||||
database: api_demo_production
|
|
||||||
username: api_demo
|
|
||||||
password: <%= ENV['API_DEMO_DATABASE_PASSWORD'] %>
|
|
||||||
{{/isDBMySQL}}
|
|
||||||
{{#isDBSQLite}}
|
|
||||||
# SQLite version 3.x
|
# SQLite version 3.x
|
||||||
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
||||||
development:
|
development:
|
||||||
@ -77,4 +20,3 @@ production:
|
|||||||
database: db/production.sqlite3
|
database: db/production.sqlite3
|
||||||
pool: 5
|
pool: 5
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
{{/isDBSQLite}}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = 'bin/rails' ] && [ "$2" = 's' ]; then
|
||||||
|
rm -f /myapp/tmp/pids/server.pid
|
||||||
|
bin/rails db:migrate
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
62
samples/server/petstore/ruby-on-rails/pom.xml
Normal file
62
samples/server/petstore/ruby-on-rails/pom.xml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.opoenapitools</groupId>
|
||||||
|
<artifactId>RORPetstoreServerTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>ROR Petstore Server</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>bundle-install</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>bundle</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
<argument>--path</argument>
|
||||||
|
<argument>vendor/bundle</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<!--<execution>
|
||||||
|
<id>bundle-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>bundle</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>exec</argument>
|
||||||
|
<argument>rspec</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>-->
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
Loading…
x
Reference in New Issue
Block a user