Last active
September 6, 2019 09:28
-
-
Save fanktom/a0aab94043697f8d9f37d914edd0783f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# create project folder | |
mkdir $1 | |
cd $1 | |
# create dockerfile | |
cat >Dockerfile <<EOL | |
FROM ruby:2.6-alpine | |
RUN apk add --no-cache --update build-base \ | |
linux-headers \ | |
git \ | |
sqlite-dev \ | |
tzdata | |
RUN mkdir /app | |
WORKDIR /app | |
COPY Gemfile /app/Gemfile | |
COPY Gemfile.lock /app/Gemfile.lock | |
RUN bundle install | |
COPY . /app | |
EXPOSE 3000 | |
EOL | |
# create gemfile to install rails into container | |
cat >Gemfile <<EOL | |
source 'https://rubygems.org' | |
gem 'rails', '~>6' | |
EOL | |
# create empty Gemfile.lock | |
touch Gemfile.lock | |
# docker-compose | |
cat >docker-compose.yml <<EOL | |
version: '3' | |
services: | |
web: | |
build: . | |
command: bundle exec rails s -p 3000 -b '0.0.0.0' | |
volumes: | |
- .:/app | |
ports: | |
- "3000:3000" | |
EOL | |
# install rails in container and create rails app | |
docker-compose build --no-cache | |
docker-compose run web rails new . --force --no-deps --database=sqlite3 --api | |
# install rubygems | |
docker-compose build | |
# setup helper scripts, all prefixed with container-* | |
cat >bin/container-update-gems <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
docker-compose run web bundle update --all | |
docker-compose run web bundle update --ruby | |
docker-compose build --pull | |
EOL | |
chmod +x bin/container-update-gems | |
cat >bin/container-restart <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
docker-compose up -d --force-recreate | |
docker-compose logs -f | |
EOL | |
chmod +x bin/container-restart | |
cat >bin/container-stop <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
EOL | |
chmod +x bin/container-stop | |
cat >bin/container-rails <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
docker-compose run web rails \$@ | |
EOL | |
chmod +x bin/container-rails |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# create project folder | |
mkdir $1 | |
cd $1 | |
# create dockerfile | |
cat >Dockerfile <<EOL | |
FROM ruby:2.6-alpine | |
RUN apk add --no-cache --update build-base \ | |
linux-headers \ | |
git \ | |
sqlite-dev \ | |
nodejs \ | |
yarn \ | |
tzdata | |
RUN mkdir /app | |
WORKDIR /app | |
COPY Gemfile /app/Gemfile | |
COPY Gemfile.lock /app/Gemfile.lock | |
RUN bundle install | |
COPY . /app | |
EXPOSE 3000 | |
EOL | |
# create gemfile to install rails into container | |
cat >Gemfile <<EOL | |
source 'https://rubygems.org' | |
gem 'rails', '~>6' | |
EOL | |
# create empty Gemfile.lock | |
touch Gemfile.lock | |
# docker-compose | |
cat >docker-compose.yml <<EOL | |
version: '3' | |
services: | |
web: | |
build: . | |
command: bundle exec rails s -p 3000 -b '0.0.0.0' | |
volumes: | |
- .:/app | |
ports: | |
- "3000:3000" | |
EOL | |
# install rails in container and create rails app | |
docker-compose build --no-cache | |
docker-compose run web rails new . --force --no-deps --database=sqlite3 --skip-coffee | |
# install rubygems | |
docker-compose build | |
# setup helper scripts, all prefixed with container-* | |
cat >bin/container-update-gems <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
docker-compose run web bundle update --all | |
docker-compose run web bundle update --ruby | |
docker-compose build --pull | |
EOL | |
chmod +x bin/container-update-gems | |
cat >bin/container-restart <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
docker-compose up -d --force-recreate | |
docker-compose logs -f | |
EOL | |
chmod +x bin/container-restart | |
cat >bin/container-stop <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
EOL | |
chmod +x bin/container-stop | |
cat >bin/container-rails <<EOL | |
#!/usr/bin/env bash | |
set -xe | |
docker-compose down | |
docker-compose run web rails \$@ | |
EOL | |
chmod +x bin/container-rails |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment