Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update Java docs from 17 to 21 java version #21138

Closed
wants to merge 13 commits into from
6 changes: 3 additions & 3 deletions content/guides/java/containerize.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ WARNING: The following Docker files already exist in this directory:
? Do you want to overwrite them? Yes
? What application platform does your project use? Java
? What's the relative directory (with a leading .) for your app? ./src
? What version of Java do you want to use? 17
? What version of Java do you want to use? 21
? What port does your server listen on? 8080
```

Expand Down Expand Up @@ -98,7 +98,7 @@ Create a file named `Dockerfile` with the following contents.
################################################################################

# Create a stage for resolving and downloading dependencies.
FROM eclipse-temurin:17-jdk-jammy as deps
FROM eclipse-temurin:21-jre-jammy as deps

WORKDIR /build

Expand Down Expand Up @@ -155,7 +155,7 @@ RUN java -Djarmode=layertools -jar target/app.jar extract --destination target/e
# most recent version of that tag when you build your Dockerfile.
# If reproducability is important, consider using a specific digest SHA, like
# eclipse-temurin@sha256:99cede493dfd88720b610eb8077c8688d3cca50003d76d1d539b0efc8cca72b4.
FROM eclipse-temurin:17-jre-jammy AS final
FROM eclipse-temurin:21-jre-jammy AS final

# Create a non-privileged user that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
Expand Down
4 changes: 2 additions & 2 deletions content/guides/java/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Replace the contents of your Dockerfile with the following.
```dockerfile {hl_lines="22-29"}
# syntax=docker/dockerfile:1

FROM eclipse-temurin:17-jdk-jammy as deps
FROM eclipse-temurin:21-jdk-jammy as deps
WORKDIR /build
COPY --chmod=0755 mvnw mvnw
COPY .mvn/ .mvn/
Expand Down Expand Up @@ -149,7 +149,7 @@ RUN cp -r /build/target/extracted/application/. ./
ENV JAVA_TOOL_OPTIONS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000
CMD [ "java", "-Dspring.profiles.active=postgres", "org.springframework.boot.loader.launch.JarLauncher" ]

FROM eclipse-temurin:17-jre-jammy AS final
FROM eclipse-temurin:21-jre-jammy AS final
ARG UID=10001
RUN adduser \
--disabled-password \
Expand Down
4 changes: 2 additions & 2 deletions content/guides/java/run-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Replace the contents of your Dockerfile with the following.
```dockerfile {hl_lines="3-19"}
# syntax=docker/dockerfile:1

FROM eclipse-temurin:17-jdk-jammy as base
FROM eclipse-temurin:21-jre-jammy as base
WORKDIR /build
COPY --chmod=0755 mvnw mvnw
COPY .mvn/ .mvn/
Expand Down Expand Up @@ -64,7 +64,7 @@ RUN cp -r /build/target/extracted/application/. ./
ENV JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000"
CMD [ "java", "-Dspring.profiles.active=postgres", "org.springframework.boot.loader.launch.JarLauncher" ]

FROM eclipse-temurin:17-jre-jammy AS final
FROM eclipse-temurin:21-jre-jammy AS final
ARG UID=10001
RUN adduser \
--disabled-password \
Expand Down
58 changes: 58 additions & 0 deletions content/language/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
description: Language-specific guides overview
keywords: guides, docker, language, node, java, python, R, go, golang, .net, c++
title: Language-specific guides overview
toc_min: 1
toc_max: 2
aliases:
- /guides/walkthroughs/containerize-your-app/
---

The language-specific guides walk you through the process of:
* Containerizing language-specific applications
* Setting up a development environment
* Configuring a CI/CD pipeline
* Deploying an application locally using Kubernetes

In addition to the language-specific modules, Docker documentation also provides guidelines to build images and efficiently manage your development environment. For more information, refer to the following topics:

* [Building best practices](../build/building/best-practices.md)
* [Build images with BuildKit](../build/buildkit/index.md#getting-started)
* [Build with Docker](../build/guide/_index.md)

## Language-specific guides

Learn how to containerize your applications and start developing using Docker. Choose one of the following languages to get started.

<div class="grid grid-cols-2 md:grid-cols-3 h-auto gap-4">
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/nodejs/"><img class="m-auto rounded" src="/language/images/nodejs.webp" alt="Develop with Node"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/python/"><img class="m-auto rounded" src="/language/images/python.webp" alt="Develop with Python"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/r/"><img class="m-auto rounded" src="/language/images/r.webp" alt="Develop with R"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/java/"><img class="m-auto rounded" src="/language/images/java.webp" alt="Develop with Java"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/golang/"><img class="m-auto rounded" src="/language/images/golang.webp" alt="Develop with Go"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/dotnet/"><img class="m-auto rounded" src="/language/images/c-sharp.webp" alt="Develop with C#"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/cpp/"><img class="m-auto rounded" src="/language/images/cpp.webp" alt="Develop with C++"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/rust/"><img class="m-auto rounded" src="/language/images/rust-logo.webp" alt="Develop with Rust"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/php/"><img class="m-auto rounded" src="/language/images/php-logo.webp" alt="Develop with PHP"></a>
</div>
<div class="flex items-center flex-1 shadow p-4">
<a href="/language/ruby/"><img class="m-auto rounded" src="/language/images/ruby-on-rails.webp" alt="Develop with Ruby"></a>
</div>
</div>
18 changes: 18 additions & 0 deletions content/language/ruby/_index.md
Original file line number Diff line number Diff line change
@@ -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 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" >}}
129 changes: 129 additions & 0 deletions content/language/ruby/configure-ci-cd.md
Original file line number Diff line number Diff line change
@@ -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
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" >}}
Loading
Loading