You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/05-containerization.md
+13-6Lines changed: 13 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,14 +70,16 @@ Refer to the [README](../README.md) doc for preparation.
70
70
```text
71
71
I'd like to build a container image of a Java app. Follow the instructions below.
72
72
73
-
- The Java app is located at `java`.
74
-
- Your working directory is the repository root.
75
73
- Identify all the steps first, which you're going to do.
74
+
- The Java app is located at `java/socialapp`.
75
+
- Your working directory is the repository root.
76
76
- Create a Dockerfile, `Dockerfile.java`.
77
77
- Use Microsoft OpenJDK 21.
78
78
- Use multi-stage build approach.
79
79
- Extract JRE from JDK.
80
80
- Use the target port number of `8080` for the container image.
81
+
- Add both environment variables, `CODESPACE_NAME` and `GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN` from the host to the container image.
82
+
- Create an SQLite database file, `sns_api.db`, in the container image. DO NOT Copy the file from the host.
81
83
```
82
84
83
85
1. Click the  button of GitHub Copilot to take the changes.
@@ -101,6 +103,7 @@ Refer to the [README](../README.md) doc for preparation.
101
103
Use the container image just built, run a container and verify if the app is running properly.
102
104
103
105
- Use the host port of `8080`.
106
+
- Both `CODESPACE_NAME` and `GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN` values should be the ones from GitHub Codespaces.
104
107
```
105
108
106
109
### Containerize .NET Application
@@ -111,13 +114,14 @@ Refer to the [README](../README.md) doc for preparation.
111
114
```text
112
115
I'd like to build a container image of a .NET app. Follow the instructions below.
113
116
117
+
- Identify all the steps first, which you're going to do.
114
118
- The .NET app is located at `dotnet`.
115
119
- Your working directory is the repository root.
116
-
- Identify all the steps first, which you're going to do.
117
120
- Create a Dockerfile, `Dockerfile.dotnet`.
118
121
- Use .NET 9.
119
122
- Use multi-stage build approach.
120
123
- Use the target port number of `8080`for the container image.
124
+
- Add the environment variable, `ApiSettings__BaseUrl` to the container. It should point to the Java app, `http://localhost:8080/api`.
121
125
```
122
126
123
127
1. Click the  button of GitHub Copilot to take the changes.
@@ -141,12 +145,13 @@ Refer to the [README](../README.md) doc for preparation.
141
145
Use the container image just built, run a container and verify if the app is running properly.
142
146
143
147
- Use the host port of `3030`.
148
+
- Pass the environment variable `ApiSettings__BaseUrl` the value of `http://localhost:8080/api`.
144
149
```
145
150
146
151
1. Make sure that both frontend and backend apps are NOT communicating with each other because they don't know each other yet. Run the prompt like below.
147
152
148
153
```text
149
-
Regardless or not, remove both containers currently running.
154
+
Remove both Java and .NET containers and their respective container images.
150
155
```
151
156
152
157
### Orchestrate Containers
@@ -157,22 +162,24 @@ Refer to the [README](../README.md) doc for preparation.
157
162
```text
158
163
I'd like to create a Docker Compose file. Follow the instructions below.
159
164
165
+
- Identify all the steps first, which you're going to do.
160
166
- Your working directory is the repository root.
161
167
- Use `Dockerfile.java` as a backend app.
162
168
- Use `Dockerfile.dotnet` as a frontend app.
163
169
- Create `compose.yaml` as the Docker Compose file.
164
170
- Use `contoso` as the network name.
165
171
- Use `contoso-backend` as the container name of the Java app. Its target port is 8080, and host port is 8080.
166
172
- Use `contoso-frontend` as the container name of the .NET app. Its target port is 8080, and host port is 3030.
167
-
- Mount the volume for the database that the Java app uses, `java/socialapp/sns_api.db`.
173
+
- Add both environment variables, `CODESPACE_NAME` and `GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN` from the host to the Java container.
174
+
- Add the environment variable, `ApiSettings__BaseUrl` to the .NET container. It should point to the Java app's `/api`.
168
175
```
169
176
170
177
1. Click the  button of GitHub Copilot to take the changes.
171
178
172
179
1. Once the `compose.yaml` file is created, run it and verify if both apps are running properly.
173
180
174
181
```text
175
-
Now, run the Docker compose file and verify if the apps are running properly.
182
+
Run the Docker compose file and verify if all the apps are running properly.
176
183
```
177
184
178
185
1. Open a web browser and navigate to `http://localhost:3030`, and verify if the apps are up and running properly.
0 commit comments