From e34f111c61320acde37f8d47af2cbe9d9a65b394 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Thu, 11 Jul 2024 15:24:47 -0600 Subject: [PATCH 01/12] Update ruby folder --- content/language/_index.md | 3 + content/language/images/ruby-on-rails.webp | Bin 0 -> 28430 bytes content/language/ruby/_index.md | 18 ++ content/language/ruby/configure-ci-cd.md | 129 ++++++++ content/language/ruby/containerize.md | 227 ++++++++++++++ content/language/ruby/deploy.md | 142 +++++++++ content/language/ruby/develop.md | 330 +++++++++++++++++++++ data/toc.yaml | 13 +- 8 files changed, 861 insertions(+), 1 deletion(-) create mode 100644 content/language/images/ruby-on-rails.webp create mode 100644 content/language/ruby/_index.md create mode 100644 content/language/ruby/configure-ci-cd.md create mode 100644 content/language/ruby/containerize.md create mode 100644 content/language/ruby/deploy.md create mode 100644 content/language/ruby/develop.md diff --git a/content/language/_index.md b/content/language/_index.md index d99d316e95a..56d0b10a4be 100644 --- a/content/language/_index.md +++ b/content/language/_index.md @@ -52,4 +52,7 @@ Learn how to containerize your applications and start developing using Docker. C
Develop with PHP
+
+ Develop with Ruby +
diff --git a/content/language/images/ruby-on-rails.webp b/content/language/images/ruby-on-rails.webp new file mode 100644 index 0000000000000000000000000000000000000000..c5c32ac545bdfd8199f20063b83b5d24a0fb5b1c GIT binary patch literal 28430 zcmeFY^;=Y3)INRy1(Xy7L{dOd=|+)~lI|`+x`!GX1VKWiQ&PI6hZX^8kggeG=o$os zk^UZh-sk!0^ACKl_nnJN&pCVT75BRL+Hq#WRh4B4?moN=004p9YbkXAz=Ht*&QDw{ z@QKAB5*PgMmX(B(1OQY;<6W5E2JbOk)n#7+6~ok9;LQ(JMNMg0XT?DP0RM&nVBp_B z@D{x8`}+{QUIl=kf1ms#`HwIt|Ih8jzZd_t_Wl+APvF1jpw9oU|GW5qKK!rmKdt}# z`_IGwr#wrWZ2=gOgqymu22gONbnxr8T?r8~2o4^eN*; zD%ACjU3`5r{(%q?dN7J^(&<~Tex|Jdl6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pzxB?E?m#Q{elsC?+QoXidL3SAX>AHItXhwmj zu?@{#mC7M^9pmf-Rk5Ha7<#LJN0$&3+2c*1{|~Rx(e7w7Co= zw9T*qa>C{*Vs{VW(th}YD`q|HQr7A}UOM3)7)PTXl-Tx&Qt9-^>6T0wzwY zg^9h9BmbL;_;2jF(u)m2v|4z*=Omf^Uqb%x7?2Jhc$88c8mLXB@TRumjY6$Q!T$qi COV>UC literal 0 HcmV?d00001 diff --git a/content/language/ruby/_index.md b/content/language/ruby/_index.md new file mode 100644 index 00000000000..b43ea5905e6 --- /dev/null +++ b/content/language/ruby/_index.md @@ -0,0 +1,18 @@ +--- +description: Containerize Ruby on Rails apps using Docker +keywords: Docker, getting started, ruby, language +title: Ruby on Rails language-specific guide +toc_min: 1 +toc_max: 2 +--- + +The Ruby on Rails language-specific guide teaches you how to containerize a Ruby on Rails application using Docker. In this guide, you’ll learn how to: + +* Containerize and run a Ruby on Rails application +* Set up a local environment to develop a Ruby on Rails application using containers +* Configure a CI/CD pipeline for a containerized Ruby on Rails application using GitHub Actions +* Deploy your containerized Ruby on Rails application locally to Kubernetes to test and debug your deployment + +Start by containerizing an existing Ruby on Rails application. + +{{< button text="Containerize a Ruby on Rails app" url="containerize.md" >}} diff --git a/content/language/ruby/configure-ci-cd.md b/content/language/ruby/configure-ci-cd.md new file mode 100644 index 00000000000..db32c44f65d --- /dev/null +++ b/content/language/ruby/configure-ci-cd.md @@ -0,0 +1,129 @@ +--- +title: Configure CI/CD for your Ruby on Rails application +keywords: ci/cd, github actions, ruby, flask +description: Learn how to configure CI/CD using GitHub Actions for your Ruby on Rails application. +--- + +## Prerequisites + +Complete all the previous sections of this guide, starting with [Containerize a Ruby on Rails application](containerize.md). You must have a [GitHub](https://github.com/signup) account and a [Docker](https://hub.docker.com/signup) account to complete this section. + +## Overview + +In this section, you'll learn how to set up and use GitHub Actions to build and test your Docker image as well as push it to Docker Hub. You will complete the following steps: + +1. Create a new repository on GitHub. +2. Define the GitHub Actions workflow. +3. Run the workflow. + +## Step one: Create the repository + +Create a GitHub repository, configure the Docker Hub credentials, and push your source code. + +1. [Create a new repository](https://github.com/new) on GitHub. + +2. Open the repository **Settings**, and go to **Secrets and variables** > + **Actions**. + +3. Create a new **Repository variable** named `DOCKER_USERNAME` and your Docker ID as value. + +4. Create a new [Personal Access Token (PAT)](../../security/for-developers/access-tokens.md/#create-an-access-token) for Docker Hub. You can name this token `docker-tutorial`. Make sure access permissions include Read and Write. + +5. Add the PAT as a **Repository secret** in your GitHub repository, with the name + `DOCKERHUB_TOKEN`. + +6. In your local repository on your machine, run the following command to change + the origin to the repository you just created. Make sure you change + `your-username` to your GitHub username and `your-repository` to the name of + the repository you created. + + ```console + $ git remote set-url origin https://github.com/your-username/your-repository.git + ``` + +7. Run the following commands to stage, commit, and push your local repository to GitHub. + + ```console + $ git add -A + $ git commit -m "my commit" + $ git push -u origin main + ``` + +## Step two: Set up the workflow + +Set up your GitHub Actions workflow for building, testing, and pushing the image +to Docker Hub. + +1. Go to your repository on GitHub and then select the **Actions** tab. + +2. Select **set up a workflow yourself**. + + This takes you to a page for creating a new GitHub actions workflow file in + your repository, under `.github/workflows/main.yml` by default. + +3. In the editor window, copy and paste the following YAML configuration. + + ```yaml + name: ci + + on: + push: + branches: + - main + + jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKER_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - + name: Build and push + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ vars.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest + ``` + + For more information about the YAML syntax for `docker/build-push-action`, + refer to the [GitHub Action README](https://github.com/docker/build-push-action/blob/master/README.md). + +## Step three: Run the workflow + +Save the workflow file and run the job. + +1. Select **Commit changes...** and push the changes to the `main` branch. + + After pushing the commit, the workflow starts automatically. + +2. Go to the **Actions** tab. It displays the workflow. + + Selecting the workflow shows you the breakdown of all the steps. + +3. When the workflow is complete, go to your + [repositories on Docker Hub](https://hub.docker.com/repositories). + + If you see the new repository in that list, it means the GitHub Actions + successfully pushed the image to Docker Hub. + +## Summary + +In this section, you learned how to set up a GitHub Actions workflow for your Ruby on Rails application. + +Related information: + - [Introduction to GitHub Actions](../../build/ci/github-actions/index.md) + - [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) + +## Next steps + +Next, learn how you can locally test and debug your workloads on Kubernetes before deploying. + +{{< button text="Test your deployment" url="./deploy.md" >}} diff --git a/content/language/ruby/containerize.md b/content/language/ruby/containerize.md new file mode 100644 index 00000000000..3f17d73a788 --- /dev/null +++ b/content/language/ruby/containerize.md @@ -0,0 +1,227 @@ +--- +title: Containerize a Ruby on Rails application +keywords: ruby, flask, containerize, initialize +description: Learn how to containerize a Ruby on Rails application. +aliases: + - /language/ruby/build-images/ + - /language/ruby/run-containers/ +--- + +## Prerequisites + +* You have installed the latest version of [Docker Desktop](../../get-docker.md). +* You have a [git client](https://git-scm.com/downloads). The examples in this section use a command-line based git client, but you can use any client. + +## Overview + +This section walks you through containerizing and running a Ruby on Rails application. + +## Get the sample application + +The sample application uses the popular [Ruby on Rails](https://rubyonrails.org/) framework. + +Clone the sample application to use with this guide. Open a terminal, change directory to a directory that you want to work in, and run the following command to clone the repository: + +```console +$ git clone https://github.com/falconcr/docker-ruby-on-rails.git +``` + +## Initialize Docker assets + +Now that you have an application, you can create the necessary Docker assets to +containerize your application. You can use Docker Desktop's built-in Docker Init +feature to help streamline the process, or you can manually create the assets. + +Docker's docker init command provides predefined configurations tailored for specific programming languages. This feature simplifies the setup process by automatically generating Dockerfiles and other necessary configuration files based on the chosen language. For example, docker init has predefined configurations for languages like Python, Java, and Node.js, making it easier to get started with Docker for these environments. + +However, it's important to note that as of now, docker init does not offer a predefined configuration for the Ruby programming language. This means that if you are working with Ruby, you'll need to create Dockerfiles and other related configurations manually. + +Inside the `docker-ruby-on-rails` directory, you should create the following files: + +Create a file named `Dockerfile` with the following contents. + +```dockerfile {collapse=true,title=Dockerfile} +# syntax=docker/dockerfile:1 + +# Use the official Ruby image with version 3.2.0 +FROM ruby:3.2.0 + +# Install dependencies +RUN apt-get update -qq && apt-get install -y \ + nodejs \ + postgresql-client \ + libssl-dev \ + libreadline-dev \ + zlib1g-dev \ + build-essential \ + curl + +# Install rbenv +RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv && \ + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && \ + echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \ + git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build && \ + echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc + +# Install the specified Ruby version using rbenv +ENV PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" +RUN rbenv install 3.2.0 && rbenv global 3.2.0 + +# Set the working directory +WORKDIR /myapp + +# Copy the Gemfile and Gemfile.lock +COPY Gemfile /myapp/Gemfile +COPY Gemfile.lock /myapp/Gemfile.lock + +# Install Gems dependencies +RUN gem install bundler && bundle install + +# Copy the application code +COPY . /myapp + +# Precompile assets (optional, if using Rails with assets) +RUN bundle exec rake assets:precompile + +# Expose the port the app runs on +EXPOSE 3000 + +# Command to run the server +CMD ["rails", "server", "-b", "0.0.0.0"] +``` + +Create a file named `compose.yaml` with the following contents. + +```yaml {collapse=true,title=compose.yaml} +version: '3' +services: + web: + build: . + command: bundle exec rails s -b '0.0.0.0' + volumes: + - .:/myapp + ports: + - "3000:3000" +``` + +Create a file named `.dockerignore` with the following contents. + +```text {collapse=true,title=".dockerignore"} +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/go/build-context-dockerignore/ + +# Ignore bundler config +/.bundle + +# Ignore all log files and tempfiles +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore the development and test databases +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore the production secrets file +/config/secrets.yml + +# Ignore all files in the test, spec, and features folders +/test/* +/spec/* +/features/* + +# Ignore system-specific files +*.swp +*.swo +*~ +*.DS_Store + +# Ignore coverage reports +/coverage/* + +# Ignore node modules (if using a JavaScript front-end with Ruby on Rails) +/node_modules + +# Ignore yarn lock file +/yarn.lock + +# Ignore the .git directory and other VCS files +.git +.gitignore + +**/docker-compose* +**/compose.y*ml +**/Dockerfile* +LICENSE +README.md +``` + +You should now have the following three files in your `docker-ruby-on-rails` +directory. + + +- .dockerignore +- compose.yaml +- Dockerfile + + +To learn more about the files, see the following: + - [Dockerfile](../../reference/dockerfile.md) + - [.dockerignore](../../reference/dockerfile.md#dockerignore-file) + - [compose.yaml](../../compose/compose-file/_index.md) + +## Run the application + +Inside the `docker-ruby-on-rails` directory, run the following command in a +terminal. + +```console +$ docker compose up --build +``` + +Open a browser and view the application at [http://localhost:8000](http://localhost:8000). You should see a simple Ruby on Rails application. + +In the terminal, press `ctrl`+`c` to stop the application. + +### Run the application in the background + +You can run the application detached from the terminal by adding the `-d` +option. Inside the `docker-ruby-on-rails` directory, run the following command +in a terminal. + +```console +$ docker compose up --build -d +``` + +Open a browser and view the application at [http://localhost:3000](http://localhost:3000). + +You should see a simple Ruby on Rails application. + +In the terminal, run the following command to stop the application. + +```console +$ docker compose down +``` + +For more information about Compose commands, see the [Compose CLI +reference](../../compose/reference/_index.md). + +## Summary + +In this section, you learned how you can containerize and run your Ruby +application using Docker. + +Related information: + - [Build with Docker guide](../../build/guide/index.md) + - [Docker Compose overview](../../compose/_index.md) + +## Next steps + +In the next section, you'll learn how you can develop your application using +containers. + +{{< button text="Develop your application" url="develop.md" >}} diff --git a/content/language/ruby/deploy.md b/content/language/ruby/deploy.md new file mode 100644 index 00000000000..370dd0a4528 --- /dev/null +++ b/content/language/ruby/deploy.md @@ -0,0 +1,142 @@ +--- +title: Test your Ruby on Rails deployment +keywords: deploy, kubernetes, ruby +description: Learn how to develop locally using Kubernetes +--- + +## Prerequisites + +- Complete all the previous sections of this guide, starting with [Containerize a Python application](containerize.md). +- [Turn on Kubernetes](/desktop/kubernetes/#install-and-turn-on-kubernetes) in Docker Desktop. + +## Overview + +In this section, you'll learn how to use Docker Desktop to deploy your application to a fully-featured Kubernetes environment on your development machine. This allows you to test and debug your workloads on Kubernetes locally before deploying. + +## Create a Kubernetes YAML file + +In your `python-docker-dev` directory, create a file named +`docker-python-kubernetes.yaml`. Open the file in an IDE or text editor and add +the following contents. Replace `DOCKER_USERNAME/REPO_NAME` with your Docker +username and the name of the repository that you created in [Configure CI/CD for +your Python application](configure-ci-cd.md). + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: docker-python-demo + namespace: default +spec: + replicas: 1 + selector: + matchLabels: + service: flask + template: + metadata: + labels: + service: flask + spec: + containers: + - name: flask-service + image: DOCKER_USERNAME/REPO_NAME + imagePullPolicy: Always + env: + - name: POSTGRES_PASSWORD + value: mysecretpassword +--- +apiVersion: v1 +kind: Service +metadata: + name: service-entrypoint + namespace: default +spec: + type: NodePort + selector: + service: flask + ports: + - port: 8001 + targetPort: 8001 + nodePort: 30001 +``` + +In this Kubernetes YAML file, there are two objects, separated by the `---`: + + - A Deployment, describing a scalable group of identical pods. In this case, + you'll get just one replica, or copy of your pod. That pod, which is + described under `template`, has just one container in it. The + container is created from the image built by GitHub Actions in [Configure CI/CD for + your Python application](configure-ci-cd.md). + - A NodePort service, which will route traffic from port 30001 on your host to + port 8001 inside the pods it routes to, allowing you to reach your app + from the network. + +To learn more about Kubernetes objects, see the [Kubernetes documentation](https://kubernetes.io/docs/home/). + +## Deploy and check your application + +1. In a terminal, navigate to `python-docker-dev` and deploy your application to + Kubernetes. + + ```console + $ kubectl apply -f docker-python-kubernetes.yaml + ``` + + You should see output that looks like the following, indicating your Kubernetes objects were created successfully. + + ```shell + deployment.apps/docker-python-demo created + service/service-entrypoint created + ``` + +2. Make sure everything worked by listing your deployments. + + ```console + $ kubectl get deployments + ``` + + Your deployment should be listed as follows: + + ```shell + NAME READY UP-TO-DATE AVAILABLE AGE + docker-python-demo 1/1 1 1 15s + ``` + + This indicates all one of the pods you asked for in your YAML are up and running. Do the same check for your services. + + ```console + $ kubectl get services + ``` + + You should get output like the following. + + ```shell + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE + kubernetes ClusterIP 10.96.0.1 443/TCP 23h + service-entrypoint NodePort 10.99.128.230 8001:30001/TCP 75s + ``` + + In addition to the default `kubernetes` service, you can see your `service-entrypoint` service, accepting traffic on port 30001/TCP. + +3. In a terminal, curl the service. Note that a database was not deployed in + this example. + + ```console + $ curl http://localhost:30001/ + Hello, Docker!!! + ``` + +4. Run the following command to tear down your application. + + ```console + $ kubectl delete -f docker-python-kubernetes.yaml + ``` + +## Summary + +In this section, you learned how to use Docker Desktop to deploy your application to a fully-featured Kubernetes environment on your development machine. + +Related information: + - [Kubernetes documentation](https://kubernetes.io/docs/home/) + - [Deploy on Kubernetes with Docker Desktop](../../desktop/kubernetes.md) + - [Swarm mode overview](../../engine/swarm/_index.md) \ No newline at end of file diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md new file mode 100644 index 00000000000..2711f7e214c --- /dev/null +++ b/content/language/ruby/develop.md @@ -0,0 +1,330 @@ +--- +title: Use containers for Ruby on Rails development +keywords: ruby, local, development +description: Learn how to develop your Ruby on Rails application locally. +--- + +## Prerequisites + +Complete [Containerize a Ruby on Rails application](containerize.md). + +## Overview + +In this section, you'll learn how to set up a development environment for your containerized application. This includes: + +- Adding a local database and persisting data +- Configuring Compose to automatically update your running Compose services as you edit and save your code + +## Get the sample application + +You'll need to clone a new repository to get a sample application that includes logic to connect to the database. + +1. Change to a directory where you want to clone the repository and run the following command. + + ```console + $ git clone https://github.com/falconcr/docker-ruby-on-rails.git + ``` + +2. In the cloned repository's directory, manually create the following files in your project directory. + + Create a file named `Dockerfile` with the following contents. + + ```dockerfile {collapse=true,title=Dockerfile} + # syntax=docker/dockerfile:1 + + # Use the official Ruby image with version 3.2.0 + FROM ruby:3.2.0 + + # Install dependencies + RUN apt-get update -qq && apt-get install -y \ + nodejs \ + postgresql-client \ + libssl-dev \ + libreadline-dev \ + zlib1g-dev \ + build-essential \ + curl + + # Install rbenv + RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv && \ + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && \ + echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \ + git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build && \ + echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc + + # Install the specified Ruby version using rbenv + ENV PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" + RUN rbenv install 3.2.0 && rbenv global 3.2.0 + + # Set the working directory + WORKDIR /myapp + + # Copy the Gemfile and Gemfile.lock + COPY Gemfile /myapp/Gemfile + COPY Gemfile.lock /myapp/Gemfile.lock + + # Install Gems dependencies + RUN gem install bundler && bundle install + + # Copy the application code + COPY . /myapp + + # Precompile assets (optional, if using Rails with assets) + RUN bundle exec rake assets:precompile + + # Expose the port the app runs on + EXPOSE 3000 + + # Command to run the server + CMD ["rails", "server", "-b", "0.0.0.0"] + + + +Create a file named `compose.yaml` with the following contents. + +```yaml {collapse=true,title=compose.yaml} +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Docker Compose reference guide at +# https://docs.docker.com/go/compose-spec-reference/ +version: '3' + services: + web: + build: . + command: bundle exec rails s -b '0.0.0.0' + volumes: + - .:/myapp + ports: + - "3000:3000" +``` + + +Create a file named `.dockerignore` with the following contents. + +```text {collapse=true,title=".dockerignore"} +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/go/build-context-dockerignore/ + +# Ignore bundler config +/.bundle + +# Ignore all log files and tempfiles +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore the development and test databases +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore the production secrets file +/config/secrets.yml + +# Ignore all files in the test, spec, and features folders +/test/* +/spec/* +/features/* + +# Ignore system-specific files +*.swp +*.swo +*~ +*.DS_Store + +# Ignore coverage reports +/coverage/* + +# Ignore node modules (if using a JavaScript front-end with Ruby on Rails) +/node_modules + +# Ignore yarn lock file +/yarn.lock + +# Ignore the .git directory and other VCS files +.git +.gitignore + +**/docker-compose* +**/compose.y*ml +**/Dockerfile* +LICENSE +README.md +``` + +## Add a local database and persist data + +You can use containers to set up local services, like a database. In this section, you'll update the `compose.yaml` file to define a database service and a volume to persist data. + +In the cloned repository's directory, open the `compose.yaml` file in an IDE or text editor. Yyou need to add the database password file as an environment variable to the server service and specify the secret file to use . + +The following is the updated `compose.yaml` file. + +```yaml {hl_lines="10-30"} +version: '3' +services: + web: + build: . + command: bundle exec rails s -b '0.0.0.0' + volumes: + - .:/myapp + ports: + - "3000:3000" + depends_on: + - db + secrets: + - db-password + environment: + - POSTGRES_PASSWORD_FILE=/run/secrets/db-password + - RAILS_ENV=development + db: + image: postgres:latest + secrets: + - db-password + environment: + - POSTGRES_PASSWORD_FILE=/run/secrets/db-password + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: +secrets: + db-password: + file: db/password.txt +``` + +> **Note** +> +> To learn more about the instructions in the Compose file, see [Compose file +> reference](/compose/compose-file/). + +Before you run the application using Compose, notice that this Compose file specifies a `password.txt` file to hold the database's password. You must create this file as it's not included in the source repository. + +In the cloned repository's directory, create a new directory named `db` and inside that directory create a file named `password.txt` that contains the password for the database. Using your favorite IDE or text editor, add the following contents to the `password.txt` file. + +```text +mysecretpassword +``` + +Save and close the `password.txt` file. + +You should now have the following contents in your `docker-ruby-on-rails` +directory. + +```text +├── docker-ruby-on-rails/ +├── app +├── bin +├── config +│── db/ +│ │ └─ password.txt +├── lib +├── log +├── public +├── storage +├── test +├── tmp +├── vendor +│ ├── .dockerignore +│ ├── .gitignore +│ ├── confi.ru +│ ├── Gemfile +│ ├── Gemfile.lock +│ ├── compose.yaml +│ ├── Rakefile +│ ├── Dockerfile +│ └── README.md +``` + +Now, run the following `docker compose up` command to start your application. + +```console +$ docker compose up --build +``` + +Refresh http://localhost:3000 in your browser and verify that the Whale items persisted, even after the containers were removed and ran again. + +Press `ctrl+c` in the terminal to stop your application. + +## Automatically update services + +Use Compose Watch to automatically update your running Compose services as you +edit and save your code. For more details about Compose Watch, see [Use Compose +Watch](../../compose/file-watch.md). + +Open your `compose.yaml` file in an IDE or text editor and then add the Compose +Watch instructions. The following is the updated `compose.yaml` file. + +```yaml {hl_lines="17-2 0"} +version: '3' +services: + web: + build: . + command: bundle exec rails s -b '0.0.0.0' + volumes: + - .:/myapp + ports: + - "3000:3000" + depends_on: + - db + secrets: + - db-password + environment: + - POSTGRES_PASSWORD_FILE=/run/secrets/db-password + - RAILS_ENV=development + develop: + watch: + - action: rebuild + path: . + db: + image: postgres:latest + secrets: + - db-password + environment: + - POSTGRES_PASSWORD_FILE=/run/secrets/db-password + volumes: + - postgres_data:/var/lib/postgresql/data + +volumes: + postgres_data: +secrets: + db-password: + file: db/password.txt +``` + +Run the following command to run your application with Compose Watch. + +```console +$ docker compose watch +``` + +Any changes to the application's source files on your local machine will now be immediately reflected in the running container. + +Open `docker-ruby-on-rails/app/views/whales/index.html.erb` in an IDE or text editor and update the `Whales` string by adding a exclamation marks. + +```diff +-

Whales

++

Whales!

+``` + +Save the changes to `index.html.erb` and then wait a few seconds for the application to rebuild. Go to the application again and verify that the updated text appears. + +Press `ctrl+c` in the terminal to stop your application. + +## Summary + +In this section, you took a look at setting up your Compose file to add a local +database and persist data. You also learned how to use Compose Watch to automatically rebuild and run your container when you update your code. + +Related information: + - [Compose file reference](/compose/compose-file/) + - [Compose file watch](../../compose/file-watch.md) + - [Multi-stage builds](../../build/building/multi-stage.md) + +## Next steps + +In the next section, you'll take a look at how to set up a CI/CD pipeline using GitHub Actions. + +{{< button text="Configure CI/CD" url="configure-ci-cd.md" >}} diff --git a/data/toc.yaml b/data/toc.yaml index 8e8d2bc21d6..cb4a23b68b5 100644 --- a/data/toc.yaml +++ b/data/toc.yaml @@ -179,7 +179,18 @@ Guides: path: /language/php/configure-ci-cd/ - title: "Test your deployment" path: /language/php/deploy/ - + - sectiontitle: Ruby + section: + - title: "Overview" + path: /language/ruby/ + - title: "Containerize your app" + path: /language/ruby/containerize/ + - title: "Develop your app" + path: /language/ruby/develop/ + - title: "Configure CI/CD" + path: /language/ruby/configure-ci-cd/ + - title: "Test your deployment" + path: /language/ruby/deploy/ - sectiontitle: Use-case guides section: - path: /guides/use-case/ From dcf220765994f224c93221295662269f73c15fd0 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Thu, 11 Jul 2024 15:53:08 -0600 Subject: [PATCH 02/12] Add deploy file --- content/language/ruby/deploy.md | 58 ++++++++++++++------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/content/language/ruby/deploy.md b/content/language/ruby/deploy.md index 370dd0a4528..51777e036ee 100644 --- a/content/language/ruby/deploy.md +++ b/content/language/ruby/deploy.md @@ -6,7 +6,7 @@ description: Learn how to develop locally using Kubernetes ## Prerequisites -- Complete all the previous sections of this guide, starting with [Containerize a Python application](containerize.md). +- Complete all the previous sections of this guide, starting with [Containerize a Ruby on Rails application](containerize.md). - [Turn on Kubernetes](/desktop/kubernetes/#install-and-turn-on-kubernetes) in Docker Desktop. ## Overview @@ -15,48 +15,45 @@ In this section, you'll learn how to use Docker Desktop to deploy your applicati ## Create a Kubernetes YAML file -In your `python-docker-dev` directory, create a file named -`docker-python-kubernetes.yaml`. Open the file in an IDE or text editor and add +In your `docker-ruby-on-rails` directory, create a file named +`docker-ruby-on-rails-kubernetes.yaml`. Open the file in an IDE or text editor and add the following contents. Replace `DOCKER_USERNAME/REPO_NAME` with your Docker username and the name of the repository that you created in [Configure CI/CD for -your Python application](configure-ci-cd.md). +your Ruby on Rails application](configure-ci-cd.md). ```yaml apiVersion: apps/v1 kind: Deployment metadata: - name: docker-python-demo + name: docker-ruby-on-rails-demo namespace: default spec: replicas: 1 selector: matchLabels: - service: flask + service: ruby-on-rails template: metadata: labels: - service: flask + service: ruby-on-rails spec: containers: - - name: flask-service + - name: ruby-on-rails-container image: DOCKER_USERNAME/REPO_NAME imagePullPolicy: Always - env: - - name: POSTGRES_PASSWORD - value: mysecretpassword --- apiVersion: v1 kind: Service metadata: - name: service-entrypoint + name: docker-ruby-on-rails-demo namespace: default spec: type: NodePort selector: - service: flask + service: ruby-on-rails ports: - - port: 8001 - targetPort: 8001 + - port: 3000 + targetPort: 3000 nodePort: 30001 ``` @@ -75,18 +72,18 @@ To learn more about Kubernetes objects, see the [Kubernetes documentation](https ## Deploy and check your application -1. In a terminal, navigate to `python-docker-dev` and deploy your application to +1. In a terminal, navigate to `docker-ruby-on-rails` and deploy your application to Kubernetes. ```console - $ kubectl apply -f docker-python-kubernetes.yaml + $ kubectl apply -f docker-ruby-on-rails-kubernetes.yaml ``` You should see output that looks like the following, indicating your Kubernetes objects were created successfully. ```shell - deployment.apps/docker-python-demo created - service/service-entrypoint created + deployment.apps/docker-ruby-on-rails-demo created + service/docker-ruby-on-rails-demo ``` 2. Make sure everything worked by listing your deployments. @@ -98,8 +95,8 @@ To learn more about Kubernetes objects, see the [Kubernetes documentation](https Your deployment should be listed as follows: ```shell - NAME READY UP-TO-DATE AVAILABLE AGE - docker-python-demo 1/1 1 1 15s + NAME READY UP-TO-DATE AVAILABLE AGE + docker-ruby-on-rails-demo 1/1 1 1 15s ``` This indicates all one of the pods you asked for in your YAML are up and running. Do the same check for your services. @@ -111,25 +108,20 @@ To learn more about Kubernetes objects, see the [Kubernetes documentation](https You should get output like the following. ```shell - NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE - kubernetes ClusterIP 10.96.0.1 443/TCP 23h - service-entrypoint NodePort 10.99.128.230 8001:30001/TCP 75s + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE + kubernetes ClusterIP 10.96.0.1 443/TCP 23h + docker-ruby-on-rails-demo NodePort 10.99.128.230 8001:30001/TCP 75s ``` - In addition to the default `kubernetes` service, you can see your `service-entrypoint` service, accepting traffic on port 30001/TCP. + In addition to the default `kubernetes` service, you can see your `docker-ruby-on-rails-demo` service, accepting traffic on port 30001/TCP. -3. In a terminal, curl the service. Note that a database was not deployed in - this example. - - ```console - $ curl http://localhost:30001/ - Hello, Docker!!! - ``` +3. IOpen the browser and go to http://localhost:30001/, you should see the ruby on rails application working. + Note that a database was not deployed in this example. 4. Run the following command to tear down your application. ```console - $ kubectl delete -f docker-python-kubernetes.yaml + $ kubectl delete -f docker-ruby-on-rails-kubernetes.yaml ``` ## Summary From 84c8a184bfbeb3bbdbe9963192e16e699b5bc65b Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Mon, 15 Jul 2024 10:21:15 -0600 Subject: [PATCH 03/12] Update deploy --- content/language/ruby/deploy.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/content/language/ruby/deploy.md b/content/language/ruby/deploy.md index 51777e036ee..93c9a7295d5 100644 --- a/content/language/ruby/deploy.md +++ b/content/language/ruby/deploy.md @@ -63,7 +63,7 @@ In this Kubernetes YAML file, there are two objects, separated by the `---`: you'll get just one replica, or copy of your pod. That pod, which is described under `template`, has just one container in it. The container is created from the image built by GitHub Actions in [Configure CI/CD for - your Python application](configure-ci-cd.md). + your Ruby on Rails application](configure-ci-cd.md). - A NodePort service, which will route traffic from port 30001 on your host to port 8001 inside the pods it routes to, allowing you to reach your app from the network. @@ -83,7 +83,7 @@ To learn more about Kubernetes objects, see the [Kubernetes documentation](https ```shell deployment.apps/docker-ruby-on-rails-demo created - service/docker-ruby-on-rails-demo + service/docker-ruby-on-rails-demo created ``` 2. Make sure everything worked by listing your deployments. @@ -114,8 +114,13 @@ To learn more about Kubernetes objects, see the [Kubernetes documentation](https ``` In addition to the default `kubernetes` service, you can see your `docker-ruby-on-rails-demo` service, accepting traffic on port 30001/TCP. + Create and migrate the database + ``` + kubectl exec -it -- rails db:migrate RAILS_ENV=development + + ``` -3. IOpen the browser and go to http://localhost:30001/, you should see the ruby on rails application working. +3. Open the browser and go to http://localhost:30001/, you should see the ruby on rails application working. Note that a database was not deployed in this example. 4. Run the following command to tear down your application. From 028df275a1ff8ec9bdb262ce38f82440e66a6763 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Mon, 15 Jul 2024 10:27:00 -0600 Subject: [PATCH 04/12] Update database --- content/language/ruby/containerize.md | 244 +++++++++++++++++++++---- content/language/ruby/develop.md | 248 ++++++++++++++++++++++---- 2 files changed, 418 insertions(+), 74 deletions(-) diff --git a/content/language/ruby/containerize.md b/content/language/ruby/containerize.md index 3f17d73a788..9c99e34d9bd 100644 --- a/content/language/ruby/containerize.md +++ b/content/language/ruby/containerize.md @@ -107,57 +107,229 @@ services: Create a file named `.dockerignore` with the following contents. ```text {collapse=true,title=".dockerignore"} -# Include any files or directories that you don't want to be copied to your -# container here (e.g., local build artifacts, temporary files, etc.). -# -# For more help, visit the .dockerignore file reference guide at -# https://docs.docker.com/go/build-context-dockerignore/ +git +.gitignore -# Ignore bundler config -/.bundle +# Created by https://www.gitignore.io/api/git,ruby,rails,jetbrains+all +# Edit at https://www.gitignore.io/?templates=git,ruby,rails,jetbrains+all + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### JetBrains+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Rails ### +*.rbc +capybara-*.html +.rspec +/db/*.sqlite3 +/db/*.sqlite3-journal +/public/system +/coverage/ +/spec/tmp +rerun.txt +pickle-email-*.html -# Ignore all log files and tempfiles +# Ignore all logfiles and tempfiles. /log/* /tmp/* !/log/.keep !/tmp/.keep -# Ignore the development and test databases -/db/*.sqlite3 -/db/*.sqlite3-journal +# TODO Comment out this rule if you are OK with secrets being uploaded to the repo +config/initializers/secret_token.rb +config/master.key -# Ignore the production secrets file -/config/secrets.yml +# Only include if you have production secrets in this file, which is no longer a Rails default +# config/secrets.yml -# Ignore all files in the test, spec, and features folders -/test/* -/spec/* -/features/* +# dotenv +# TODO Comment out this rule if environment variables can be committed +.env -# Ignore system-specific files -*.swp -*.swo -*~ -*.DS_Store +## Environment normalization: +/.bundle +/vendor/bundle + +# these should all be checked in to normalize the environment: +# Gemfile.lock, .ruby-version, .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +# if using bower-rails ignore default bower_components path bower.json files +/vendor/assets/bower_components +*.bowerrc +bower.json + +# Ignore pow environment settings +.powenv + +# Ignore Byebug command history file. +.byebug_history + +# Ignore node_modules +node_modules/ + +# Ignore precompiled javascript packs +/public/packs +/public/packs-test +/public/assets + +# Ignore yarn files +/yarn-error.log +yarn-debug.log* +.yarn-integrity + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +### Ruby ### +*.gem +/.config +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +# Ignore Byebug command history file. + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# vendor/Pods/ -# Ignore coverage reports -/coverage/* +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ -# Ignore node modules (if using a JavaScript front-end with Ruby on Rails) -/node_modules +/.bundle/ +/lib/bundler/man/ -# Ignore yarn lock file -/yarn.lock +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset -# Ignore the .git directory and other VCS files -.git -.gitignore +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: -**/docker-compose* -**/compose.y*ml -**/Dockerfile* -LICENSE -README.md +# End of https://www.gitignore.io/api/git,ruby,rails,jetbrains+all ``` You should now have the following three files in your `docker-ruby-on-rails` diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index 2711f7e214c..fa8b3370534 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -101,57 +101,229 @@ version: '3' Create a file named `.dockerignore` with the following contents. ```text {collapse=true,title=".dockerignore"} -# Include any files or directories that you don't want to be copied to your -# container here (e.g., local build artifacts, temporary files, etc.). -# -# For more help, visit the .dockerignore file reference guide at -# https://docs.docker.com/go/build-context-dockerignore/ +git +.gitignore -# Ignore bundler config -/.bundle +# Created by https://www.gitignore.io/api/git,ruby,rails,jetbrains+all +# Edit at https://www.gitignore.io/?templates=git,ruby,rails,jetbrains+all + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### JetBrains+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Rails ### +*.rbc +capybara-*.html +.rspec +/db/*.sqlite3 +/db/*.sqlite3-journal +/public/system +/coverage/ +/spec/tmp +rerun.txt +pickle-email-*.html -# Ignore all log files and tempfiles +# Ignore all logfiles and tempfiles. /log/* /tmp/* !/log/.keep !/tmp/.keep -# Ignore the development and test databases -/db/*.sqlite3 -/db/*.sqlite3-journal +# TODO Comment out this rule if you are OK with secrets being uploaded to the repo +config/initializers/secret_token.rb +config/master.key -# Ignore the production secrets file -/config/secrets.yml +# Only include if you have production secrets in this file, which is no longer a Rails default +# config/secrets.yml -# Ignore all files in the test, spec, and features folders -/test/* -/spec/* -/features/* +# dotenv +# TODO Comment out this rule if environment variables can be committed +.env -# Ignore system-specific files -*.swp -*.swo -*~ -*.DS_Store +## Environment normalization: +/.bundle +/vendor/bundle + +# these should all be checked in to normalize the environment: +# Gemfile.lock, .ruby-version, .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +# if using bower-rails ignore default bower_components path bower.json files +/vendor/assets/bower_components +*.bowerrc +bower.json + +# Ignore pow environment settings +.powenv + +# Ignore Byebug command history file. +.byebug_history + +# Ignore node_modules +node_modules/ + +# Ignore precompiled javascript packs +/public/packs +/public/packs-test +/public/assets + +# Ignore yarn files +/yarn-error.log +yarn-debug.log* +.yarn-integrity + +# Ignore uploaded files in development +/storage/* +!/storage/.keep + +### Ruby ### +*.gem +/.config +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +# Used by dotenv library to load environment variables. +# .env + +# Ignore Byebug command history file. + +## Specific to RubyMotion: +.dat* +.repl_history +build/ +*.bridgesupport +build-iPhoneOS/ +build-iPhoneSimulator/ + +## Specific to RubyMotion (use of CocoaPods): +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# vendor/Pods/ -# Ignore coverage reports -/coverage/* +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ -# Ignore node modules (if using a JavaScript front-end with Ruby on Rails) -/node_modules +/.bundle/ +/lib/bundler/man/ -# Ignore yarn lock file -/yarn.lock +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset -# Ignore the .git directory and other VCS files -.git -.gitignore +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: -**/docker-compose* -**/compose.y*ml -**/Dockerfile* -LICENSE -README.md +# End of https://www.gitignore.io/api/git,ruby,rails,jetbrains+all ``` ## Add a local database and persist data @@ -178,7 +350,7 @@ services: - db-password environment: - POSTGRES_PASSWORD_FILE=/run/secrets/db-password - - RAILS_ENV=development + - RAILS_ENV=test db: image: postgres:latest secrets: @@ -273,7 +445,7 @@ services: - db-password environment: - POSTGRES_PASSWORD_FILE=/run/secrets/db-password - - RAILS_ENV=development + - RAILS_ENV=test develop: watch: - action: rebuild From 9b651c345c3d88db1f2ded1e5800d75f24dbf38f Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Wed, 17 Jul 2024 10:54:44 -0600 Subject: [PATCH 05/12] Update files from codereview --- content/language/ruby/_index.md | 2 +- content/language/ruby/containerize.md | 11 +- content/language/ruby/develop.md | 361 ++------------------------ 3 files changed, 30 insertions(+), 344 deletions(-) diff --git a/content/language/ruby/_index.md b/content/language/ruby/_index.md index b43ea5905e6..2da18bcabb1 100644 --- a/content/language/ruby/_index.md +++ b/content/language/ruby/_index.md @@ -6,7 +6,7 @@ toc_min: 1 toc_max: 2 --- -The Ruby on Rails language-specific guide teaches you how to containerize a Ruby on Rails application using Docker. In this guide, you’ll learn how to: +The Ruby language-specific guide teaches you how to containerize a Ruby on Rails application using Docker. In this guide, you’ll learn how to: * Containerize and run a Ruby on Rails application * Set up a local environment to develop a Ruby on Rails application using containers diff --git a/content/language/ruby/containerize.md b/content/language/ruby/containerize.md index 9c99e34d9bd..9b3bd270db1 100644 --- a/content/language/ruby/containerize.md +++ b/content/language/ruby/containerize.md @@ -10,7 +10,7 @@ aliases: ## Prerequisites * You have installed the latest version of [Docker Desktop](../../get-docker.md). -* You have a [git client](https://git-scm.com/downloads). The examples in this section use a command-line based git client, but you can use any client. +* You have a [Git client](https://git-scm.com/downloads). The examples in this section show the Git CLI, but you can use any client. ## Overview @@ -32,11 +32,9 @@ Now that you have an application, you can create the necessary Docker assets to containerize your application. You can use Docker Desktop's built-in Docker Init feature to help streamline the process, or you can manually create the assets. -Docker's docker init command provides predefined configurations tailored for specific programming languages. This feature simplifies the setup process by automatically generating Dockerfiles and other necessary configuration files based on the chosen language. For example, docker init has predefined configurations for languages like Python, Java, and Node.js, making it easier to get started with Docker for these environments. +`docker init`, the command for bootstrapping the Docker-related assets for a project, does not yet support the Ruby programming language. This means that if you are working with Ruby, you'll need to create Dockerfiles and other related configurations manually. -However, it's important to note that as of now, docker init does not offer a predefined configuration for the Ruby programming language. This means that if you are working with Ruby, you'll need to create Dockerfiles and other related configurations manually. - -Inside the `docker-ruby-on-rails` directory, you should create the following files: +Inside the `docker-ruby-on-rails` directory, create the following files: Create a file named `Dockerfile` with the following contents. @@ -93,7 +91,6 @@ CMD ["rails", "server", "-b", "0.0.0.0"] Create a file named `compose.yaml` with the following contents. ```yaml {collapse=true,title=compose.yaml} -version: '3' services: web: build: . @@ -355,7 +352,7 @@ terminal. $ docker compose up --build ``` -Open a browser and view the application at [http://localhost:8000](http://localhost:8000). You should see a simple Ruby on Rails application. +Open a browser and view the application at [http://localhost:3000](http://localhost:3000). You should see a simple Ruby on Rails application. In the terminal, press `ctrl`+`c` to stop the application. diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index fa8b3370534..3ecc832b351 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -15,317 +15,6 @@ In this section, you'll learn how to set up a development environment for your c - Adding a local database and persisting data - Configuring Compose to automatically update your running Compose services as you edit and save your code -## Get the sample application - -You'll need to clone a new repository to get a sample application that includes logic to connect to the database. - -1. Change to a directory where you want to clone the repository and run the following command. - - ```console - $ git clone https://github.com/falconcr/docker-ruby-on-rails.git - ``` - -2. In the cloned repository's directory, manually create the following files in your project directory. - - Create a file named `Dockerfile` with the following contents. - - ```dockerfile {collapse=true,title=Dockerfile} - # syntax=docker/dockerfile:1 - - # Use the official Ruby image with version 3.2.0 - FROM ruby:3.2.0 - - # Install dependencies - RUN apt-get update -qq && apt-get install -y \ - nodejs \ - postgresql-client \ - libssl-dev \ - libreadline-dev \ - zlib1g-dev \ - build-essential \ - curl - - # Install rbenv - RUN git clone https://github.com/rbenv/rbenv.git ~/.rbenv && \ - echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && \ - echo 'eval "$(rbenv init -)"' >> ~/.bashrc && \ - git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build && \ - echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc - - # Install the specified Ruby version using rbenv - ENV PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" - RUN rbenv install 3.2.0 && rbenv global 3.2.0 - - # Set the working directory - WORKDIR /myapp - - # Copy the Gemfile and Gemfile.lock - COPY Gemfile /myapp/Gemfile - COPY Gemfile.lock /myapp/Gemfile.lock - - # Install Gems dependencies - RUN gem install bundler && bundle install - - # Copy the application code - COPY . /myapp - - # Precompile assets (optional, if using Rails with assets) - RUN bundle exec rake assets:precompile - - # Expose the port the app runs on - EXPOSE 3000 - - # Command to run the server - CMD ["rails", "server", "-b", "0.0.0.0"] - - - -Create a file named `compose.yaml` with the following contents. - -```yaml {collapse=true,title=compose.yaml} -# Comments are provided throughout this file to help you get started. -# If you need more help, visit the Docker Compose reference guide at -# https://docs.docker.com/go/compose-spec-reference/ -version: '3' - services: - web: - build: . - command: bundle exec rails s -b '0.0.0.0' - volumes: - - .:/myapp - ports: - - "3000:3000" -``` - - -Create a file named `.dockerignore` with the following contents. - -```text {collapse=true,title=".dockerignore"} -git -.gitignore - -# Created by https://www.gitignore.io/api/git,ruby,rails,jetbrains+all -# Edit at https://www.gitignore.io/?templates=git,ruby,rails,jetbrains+all - -### Git ### -# Created by git for backups. To disable backups in Git: -# $ git config --global mergetool.keepBackup false -*.orig - -# Created by git when using merge tools for conflicts -*.BACKUP.* -*.BASE.* -*.LOCAL.* -*.REMOTE.* -*_BACKUP_*.txt -*_BASE_*.txt -*_LOCAL_*.txt -*_REMOTE_*.txt - -### JetBrains+all ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### JetBrains+all Patch ### -# Ignores the whole .idea folder and all .iml files -# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 - -.idea/ - -# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 - -*.iml -modules.xml -.idea/misc.xml -*.ipr - -# Sonarlint plugin -.idea/sonarlint - -### Rails ### -*.rbc -capybara-*.html -.rspec -/db/*.sqlite3 -/db/*.sqlite3-journal -/public/system -/coverage/ -/spec/tmp -rerun.txt -pickle-email-*.html - -# Ignore all logfiles and tempfiles. -/log/* -/tmp/* -!/log/.keep -!/tmp/.keep - -# TODO Comment out this rule if you are OK with secrets being uploaded to the repo -config/initializers/secret_token.rb -config/master.key - -# Only include if you have production secrets in this file, which is no longer a Rails default -# config/secrets.yml - -# dotenv -# TODO Comment out this rule if environment variables can be committed -.env - -## Environment normalization: -/.bundle -/vendor/bundle - -# these should all be checked in to normalize the environment: -# Gemfile.lock, .ruby-version, .ruby-gemset - -# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: -.rvmrc - -# if using bower-rails ignore default bower_components path bower.json files -/vendor/assets/bower_components -*.bowerrc -bower.json - -# Ignore pow environment settings -.powenv - -# Ignore Byebug command history file. -.byebug_history - -# Ignore node_modules -node_modules/ - -# Ignore precompiled javascript packs -/public/packs -/public/packs-test -/public/assets - -# Ignore yarn files -/yarn-error.log -yarn-debug.log* -.yarn-integrity - -# Ignore uploaded files in development -/storage/* -!/storage/.keep - -### Ruby ### -*.gem -/.config -/InstalledFiles -/pkg/ -/spec/reports/ -/spec/examples.txt -/test/tmp/ -/test/version_tmp/ -/tmp/ - -# Used by dotenv library to load environment variables. -# .env - -# Ignore Byebug command history file. - -## Specific to RubyMotion: -.dat* -.repl_history -build/ -*.bridgesupport -build-iPhoneOS/ -build-iPhoneSimulator/ - -## Specific to RubyMotion (use of CocoaPods): -# -# We recommend against adding the Pods directory to your .gitignore. However -# you should judge for yourself, the pros and cons are mentioned at: -# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control -# vendor/Pods/ - -## Documentation cache and generated files: -/.yardoc/ -/_yardoc/ -/doc/ -/rdoc/ - -/.bundle/ -/lib/bundler/man/ - -# for a library or gem, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# Gemfile.lock -# .ruby-version -# .ruby-gemset - -# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: - -# End of https://www.gitignore.io/api/git,ruby,rails,jetbrains+all -``` - ## Add a local database and persist data You can use containers to set up local services, like a database. In this section, you'll update the `compose.yaml` file to define a database service and a volume to persist data. @@ -335,7 +24,6 @@ In the cloned repository's directory, open the `compose.yaml` file in an IDE or The following is the updated `compose.yaml` file. ```yaml {hl_lines="10-30"} -version: '3' services: web: build: . @@ -386,28 +74,30 @@ You should now have the following contents in your `docker-ruby-on-rails` directory. ```text -├── docker-ruby-on-rails/ -├── app -├── bin -├── config -│── db/ -│ │ └─ password.txt -├── lib -├── log -├── public -├── storage -├── test -├── tmp -├── vendor -│ ├── .dockerignore -│ ├── .gitignore -│ ├── confi.ru -│ ├── Gemfile -│ ├── Gemfile.lock -│ ├── compose.yaml -│ ├── Rakefile -│ ├── Dockerfile -│ └── README.md +. +├── Dockerfile +├── Gemfile +├── Gemfile.lock +├── README.md +├── Rakefile +├── app/ +├── bin/ +├── compose.yaml +├── config/ +├── config.ru +├── db/ +│ ├── development.sqlite3 +│ ├── migrate +│ ├── password.txt +│ ├── schema.rb +│ └── seeds.rb +├── lib/ +├── log/ +├── public/ +├── storage/ +├── test/ +├── tmp/ +└── vendor ``` Now, run the following `docker compose up` command to start your application. @@ -415,8 +105,7 @@ Now, run the following `docker compose up` command to start your application. ```console $ docker compose up --build ``` - -Refresh http://localhost:3000 in your browser and verify that the Whale items persisted, even after the containers were removed and ran again. +Refresh in your browser and verify that the Whale items persisted, even after the containers were removed and ran again.u Press `ctrl+c` in the terminal to stop your application. From 2b01977d744684521288c1fc56875a19a8662d74 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Wed, 17 Jul 2024 13:38:59 -0600 Subject: [PATCH 06/12] Update develop md --- content/language/ruby/develop.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index 3ecc832b351..d5cc9501965 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -105,7 +105,23 @@ Now, run the following `docker compose up` command to start your application. ```console $ docker compose up --build ``` -Refresh in your browser and verify that the Whale items persisted, even after the containers were removed and ran again.u + +In Ruby on Rails, `db:migrate` is a Rake task that is used to run migrations on the database. Migrations are a way to alter the structure of your database schema over time in a consistent and easy way. + +```console +$ docker exec -it docker-ruby-on-rails-web-1 rake db:migrate RAILS_ENV=test +``` + +You will see a similar message like this: + +``console +== 20240710193146 CreateWhales: migrating ===================================== +-- create_table(:whales) + -> 0.0126s +== 20240710193146 CreateWhales: migrated (0.0127s) ============================ +`` + +Refresh in your browser and verify that the Whale items persisted, even after the containers were removed and ran again. Press `ctrl+c` in the terminal to stop your application. From f364df685041e5b403350e7166f9353e46ed7936 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Wed, 17 Jul 2024 13:43:21 -0600 Subject: [PATCH 07/12] Add whales --- content/language/ruby/develop.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index d5cc9501965..948f2a90617 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -121,9 +121,9 @@ You will see a similar message like this: == 20240710193146 CreateWhales: migrated (0.0127s) ============================ `` -Refresh in your browser and verify that the Whale items persisted, even after the containers were removed and ran again. +Refresh in your browser and add the whales. -Press `ctrl+c` in the terminal to stop your application. +Press `ctrl+c` in the terminal to stop your application and run `docker compose up` again, the whales are being persisted. ## Automatically update services From 87fd767ed6996eb6a0dcda937baa74b404b8d520 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Wed, 17 Jul 2024 13:57:45 -0600 Subject: [PATCH 08/12] Add env file --- content/language/ruby/develop.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index 948f2a90617..bc6c6140c6b 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -23,7 +23,7 @@ In the cloned repository's directory, open the `compose.yaml` file in an IDE or The following is the updated `compose.yaml` file. -```yaml {hl_lines="10-30"} +```yaml {hl_lines="09-30"} services: web: build: . @@ -34,11 +34,9 @@ services: - "3000:3000" depends_on: - db - secrets: - - db-password environment: - - POSTGRES_PASSWORD_FILE=/run/secrets/db-password - RAILS_ENV=test + env_file: "webapp.env" db: image: postgres:latest secrets: @@ -68,7 +66,7 @@ In the cloned repository's directory, create a new directory named `db` and insi mysecretpassword ``` -Save and close the `password.txt` file. +Save and close the `password.txt` file. In addition, in the file `webapp.env` you can change the password to connect to the database. You should now have the following contents in your `docker-ruby-on-rails` directory. From 65c850cc6ce9434897dd1409dc746c5dabe26761 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Wed, 24 Jul 2024 09:22:29 -0600 Subject: [PATCH 09/12] Apply changes --- content/language/ruby/deploy.md | 4 ++-- content/language/ruby/develop.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/language/ruby/deploy.md b/content/language/ruby/deploy.md index 93c9a7295d5..cf9a5d40059 100644 --- a/content/language/ruby/deploy.md +++ b/content/language/ruby/deploy.md @@ -11,7 +11,7 @@ description: Learn how to develop locally using Kubernetes ## Overview -In this section, you'll learn how to use Docker Desktop to deploy your application to a fully-featured Kubernetes environment on your development machine. This allows you to test and debug your workloads on Kubernetes locally before deploying. +In this section, you'll learn how to use Docker Desktop to deploy your application to a fully-featured Kubernetes environment on your development machine. This lets you to test and debug your workloads on Kubernetes locally before deploying. ## Create a Kubernetes YAML file @@ -120,7 +120,7 @@ To learn more about Kubernetes objects, see the [Kubernetes documentation](https ``` -3. Open the browser and go to http://localhost:30001/, you should see the ruby on rails application working. +3. Open the browser and go to HTTP://localhost:30001/, you should see the ruby on rails application working. Note that a database was not deployed in this example. 4. Run the following command to tear down your application. diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index bc6c6140c6b..60cc350260b 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -19,7 +19,7 @@ In this section, you'll learn how to set up a development environment for your c You can use containers to set up local services, like a database. In this section, you'll update the `compose.yaml` file to define a database service and a volume to persist data. -In the cloned repository's directory, open the `compose.yaml` file in an IDE or text editor. Yyou need to add the database password file as an environment variable to the server service and specify the secret file to use . +In the cloned repository's directory, open the `compose.yaml` file in an IDE or text editor. You need to add the database password file as an environment variable to the server service and specify the secret file to use . The following is the updated `compose.yaml` file. From a504f3a106a72707ca543917633cd161c909db58 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Thu, 25 Jul 2024 08:48:02 -0600 Subject: [PATCH 10/12] Apply feedback from craig --- content/language/ruby/deploy.md | 35 ++++++++++++++++++++++++++------ content/language/ruby/develop.md | 14 ++++--------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/content/language/ruby/deploy.md b/content/language/ruby/deploy.md index cf9a5d40059..38474713026 100644 --- a/content/language/ruby/deploy.md +++ b/content/language/ruby/deploy.md @@ -110,20 +110,43 @@ To learn more about Kubernetes objects, see the [Kubernetes documentation](https ```shell NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 443/TCP 23h - docker-ruby-on-rails-demo NodePort 10.99.128.230 8001:30001/TCP 75s + docker-ruby-on-rails-demo NodePort 10.99.128.230 3000:30001/TCP 75s ``` In addition to the default `kubernetes` service, you can see your `docker-ruby-on-rails-demo` service, accepting traffic on port 30001/TCP. - Create and migrate the database + + +3. To create and migrate the database in a Ruby on Rails application running on Kubernetes, you need to follow these steps. + + **Get the Current Pods**: + First, you need to identify the pods running in your Kubernetes cluster. Execute the following command to list the current pods in the `default` namespace: + + ```sh + # Get the current pods in the cluster in the namespace default + $ kubectl get pods + ``` + + This command will display a list of all pods in the `default` namespace. Look for the pod with the prefix `docker-ruby-on-rails-demo-`. Here is an example output: + + ```console + NAME READY STATUS RESTARTS AGE + docker-ruby-on-rails-demo-7cbddb5d6f-qh44l 1/1 Running 2 (22h ago) 9d ``` - kubectl exec -it -- rails db:migrate RAILS_ENV=development + **Execute the Migration Command**: + Once you've identified the correct pod, use the `kubectl exec` command to run the database migration inside the pod. + + ```sh + $ kubectl exec -it docker-ruby-on-rails-demo-7cbddb5d6f-qh44l -- rails db:migrate RAILS_ENV=development ``` -3. Open the browser and go to HTTP://localhost:30001/, you should see the ruby on rails application working. - Note that a database was not deployed in this example. + This command opens an interactive terminal session (`-it`) in the specified pod and runs the `rails db:migrate` command with the environment set to development (`RAILS_ENV=development`). + + By following these steps, you ensure that your database is properly migrated within the Ruby on Rails application running in your Kubernetes cluster. This process helps maintain the integrity and consistency of your application's data structure during deployment and updates. + +4. Open the browser and go to [http://localhost:30001](http://localhost:30001), you should see the ruby on rails application working. -4. Run the following command to tear down your application. +5. Run the following command to tear down your application. ```console $ kubectl delete -f docker-ruby-on-rails-kubernetes.yaml diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index 60cc350260b..3dccb48ad8e 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -19,7 +19,7 @@ In this section, you'll learn how to set up a development environment for your c You can use containers to set up local services, like a database. In this section, you'll update the `compose.yaml` file to define a database service and a volume to persist data. -In the cloned repository's directory, open the `compose.yaml` file in an IDE or text editor. You need to add the database password file as an environment variable to the server service and specify the secret file to use . +In the cloned repository's directory, open the `compose.yaml` file in an IDE or text editor. You need to add the database password file as an environment variable to the server service and specify the secret file to use. The following is the updated `compose.yaml` file. @@ -28,8 +28,6 @@ services: web: build: . command: bundle exec rails s -b '0.0.0.0' - volumes: - - .:/myapp ports: - "3000:3000" depends_on: @@ -132,23 +130,19 @@ Watch](../../compose/file-watch.md). Open your `compose.yaml` file in an IDE or text editor and then add the Compose Watch instructions. The following is the updated `compose.yaml` file. -```yaml {hl_lines="17-2 0"} -version: '3' +```yaml {hl_lines="16-19"} services: web: build: . command: bundle exec rails s -b '0.0.0.0' - volumes: - - .:/myapp ports: - "3000:3000" depends_on: - db - secrets: - - db-password environment: - - POSTGRES_PASSWORD_FILE=/run/secrets/db-password - RAILS_ENV=test + env_file: "webapp.env" + develop: watch: - action: rebuild From 674c6e00f1d485b00d057942a804a231beeb1468 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Mon, 29 Jul 2024 12:14:11 -0600 Subject: [PATCH 11/12] Delete mr64 --- content/language/ruby/configure-ci-cd.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/language/ruby/configure-ci-cd.md b/content/language/ruby/configure-ci-cd.md index db32c44f65d..b54d7b112e7 100644 --- a/content/language/ruby/configure-ci-cd.md +++ b/content/language/ruby/configure-ci-cd.md @@ -88,7 +88,7 @@ to Docker Hub. name: Build and push uses: docker/build-push-action@v6 with: - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 push: true tags: ${{ vars.DOCKER_USERNAME }}/${{ github.event.repository.name }}:latest ``` From e20e824845eb2e9ce89d19fa21f25eea22eb84d7 Mon Sep 17 00:00:00 2001 From: Gerardo Lopez Date: Tue, 30 Jul 2024 16:18:00 -0600 Subject: [PATCH 12/12] apply feedback --- content/language/ruby/develop.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/language/ruby/develop.md b/content/language/ruby/develop.md index 3dccb48ad8e..3738e8cd6a4 100644 --- a/content/language/ruby/develop.md +++ b/content/language/ruby/develop.md @@ -23,7 +23,7 @@ In the cloned repository's directory, open the `compose.yaml` file in an IDE or The following is the updated `compose.yaml` file. -```yaml {hl_lines="09-30"} +```yaml {hl_lines="07-25"} services: web: build: . @@ -130,7 +130,7 @@ Watch](../../compose/file-watch.md). Open your `compose.yaml` file in an IDE or text editor and then add the Compose Watch instructions. The following is the updated `compose.yaml` file. -```yaml {hl_lines="16-19"} +```yaml {hl_lines="13-16"} services: web: build: .