Skip to content

Commit fcf703e

Browse files
authored
Merge pull request #706 from jasonrandrews/new-LP
new Learning Path for Supervisor in a Docker container
2 parents 0e1176a + 49340eb commit fcf703e

File tree

13 files changed

+497
-23
lines changed

13 files changed

+497
-23
lines changed

content/install-guides/aws-copilot.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
additional_search_terms:
3+
- cloud
4+
- deploy
5+
6+
7+
layout: installtoolsall
8+
minutes_to_complete: 10
9+
author_primary: Jason Andrews
10+
multi_install: false
11+
multitool_install_part: false
12+
official_docs: https://aws.github.io/copilot-cli/
13+
test_images:
14+
- ubuntu:latest
15+
test_link: null
16+
test_maintenance: false
17+
test_status:
18+
- passed
19+
title: AWS Copilot CLI
20+
tool_install: true
21+
weight: 1
22+
---
23+
24+
AWS Copilot CLI is an open source command line interface for running containers on AWS App Runner, Amazon Elastic Container Service (ECS), and AWS Fargate.
25+
26+
It is available for a variety of operating systems and Linux distributions and supports the Arm architecture.
27+
28+
## Before you begin
29+
30+
This article provides quick solutions to install the latest version of AWS Copilot CLI for Ubuntu on Arm and macOS.
31+
32+
Confirm you are using an Arm computer by running:
33+
34+
```bash { target="ubuntu:latest" }
35+
uname -m
36+
```
37+
38+
If you are on Arm Linux the output should be:
39+
40+
```output
41+
aarch64
42+
```
43+
44+
If you are on macOS with Apple Silicon the output should be:
45+
46+
```output
47+
arm64
48+
```
49+
50+
## Download and install AWS Copilot CLI
51+
52+
Copilot requires Docker. Refer to the [Docker](/install-guides/docker/) install guide for installation instructions.
53+
54+
If you are using Docker on Linux you will need to install QEMU to build container images for both the `arm64` and the `amd64` architectures.
55+
56+
```console
57+
sudo apt-get install qemu-user-static
58+
```
59+
60+
Docker Desktop for macOS includes the ability to build for multiple architectures, so you don't need to do anything extra.
61+
62+
To install Copilot on Arm Linux:
63+
64+
```console
65+
sudo curl -Lo /usr/local/bin/copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux-arm64 \
66+
&& sudo chmod +x /usr/local/bin/copilot \
67+
&& copilot --help
68+
```
69+
70+
To install Copilot on macOS:
71+
72+
```console
73+
curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-darwin && chmod +x copilot && sudo mv copilot /usr/local/bin/copilot && copilot --help
74+
```
75+
76+
Verify Copilot CLI is installed by running:
77+
78+
```console
79+
copilot --version
80+
```
81+
The version should be printed:
82+
83+
```output
84+
copilot version: v1.33.0
85+
```

content/learning-paths/servers-and-cloud-computing/aws-copilot/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ learning_objectives:
1212

1313
prerequisites:
1414
- An Amazon Web Services (AWS) account
15-
- A local computer with Docker installed
15+
- A local computer with Docker, AWS CLI, and AWS Copilot CLI installed
1616

1717
author_primary: Jason Andrews
1818

content/learning-paths/servers-and-cloud-computing/aws-copilot/app.md

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,15 @@ Graviton2 is not the default for Copilot, but read on to find out how to set the
1616
This guide is applicable to both Linux and macOS users.
1717

1818
Before starting, ensure you have Docker and Copilot installed on your computer.
19-
For Docker installation, refer to the [Docker install guide](https://learn.arm.com/install-guides/docker/).
20-
21-
You will also need an AWS account, which you can create at https://aws.amazon.com. (Click on **Create an AWS Account** in the top right corner. Follow the instructions to register. See the [Creating an AWS account documentation](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-creating.html) for full instructions.)
2219

23-
Make sure to configure your access key ID and secret access key, which are used to sign programmatic requests that you make to AWS. Refer to [AWS Credentials](https://learn.arm.com/install-guides/aws_access_keys/) for a quick summary of how to run `aws configure`. The install guide also covers how to install the AWS CLI. Make a note of the AWS region you set with `aws configure` so you can see the resources created by Copilot in the AWS console.
24-
25-
If you are using Docker on Linux you will need to install QEMU to build container images for both the `arm64` and the `amd64` architectures.
26-
27-
```console
28-
sudo apt-get install qemu-user-static
29-
```
30-
31-
Docker Desktop for macOS includes the ability to build for multiple architectures, so you don't need to do anything extra.
20+
For Docker installation, refer to the [Docker install guide](https://learn.arm.com/install-guides/docker/).
3221

33-
To install Copilot on Arm Linux:
22+
For Copilot installation, refer to the [AWS Copilot CLI install guide](/install-guides/aws-copilot).
3423

35-
```console
36-
sudo curl -Lo /usr/local/bin/copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-linux-arm64 \
37-
&& sudo chmod +x /usr/local/bin/copilot \
38-
&& copilot --help
39-
```
24+
You will also need an AWS account, which you can create at https://aws.amazon.com. (Click on **Create an AWS Account** in the top right corner. Follow the instructions to register. See the [Creating an AWS account documentation](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-creating.html) for full instructions.)
4025

41-
To install Copilot on macOS:
26+
Make sure to configure your access key ID and secret access key, which are used to sign programmatic requests that you make to AWS. Refer to [AWS Credentials](/install-guides/aws_access_keys/) for a quick summary of how to run `aws configure`. The install guide also covers how to install the AWS CLI. Make a note of the AWS region you set with `aws configure` so you can see the resources created by Copilot in the AWS console.
4227

43-
```console
44-
curl -Lo copilot https://github.com/aws/copilot-cli/releases/latest/download/copilot-darwin && chmod +x copilot && sudo mv copilot /usr/local/bin/copilot && copilot --help
45-
```
4628

4729
# Create an example application
4830

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: Access running containers using Supervisor, SSH, and Remote.It
3+
4+
minutes_to_complete: 60
5+
6+
who_is_this_for: This is an introductory topic for software developers who want to learn how to run multiple services in a container and access running containers using Supervisor, SSH, and Remote.It during the debug and test phases of a project.
7+
8+
learning_objectives:
9+
- Use Supervisor to run multiple services in a container
10+
- Access a container running in AWS Fargate without changing the security group for debug and test
11+
12+
prerequisites:
13+
- An Arm Linux computer running Docker
14+
- An AWS account
15+
- A Remote.It account
16+
17+
author_primary: Jason Andrews
18+
19+
### Tags
20+
skilllevels: Introductory
21+
subjects: Performance and Architecture
22+
armips:
23+
- Neoverse
24+
- Cortex-A
25+
operatingsystems:
26+
- Linux
27+
tools_software_languages:
28+
- Docker
29+
- Remote.It
30+
- Supervisor
31+
32+
### FIXED, DO NOT MODIFY
33+
# ================================================================================
34+
weight: 1 # _index.md always has weight of 1 to order correctly
35+
layout: "learningpathall" # All files under learning paths have this same wrapper
36+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
37+
---
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
# ================================================================================
3+
# Edit
4+
# ================================================================================
5+
6+
next_step_guidance: >
7+
You may also be interested in Kubernetes on Arm.
8+
# 1-3 sentence recommendation outlining how the reader can generally keep learning about these topics, and a specific explanation of why the next step is being recommended.
9+
10+
recommended_path: "/learning-paths/servers-and-cloud-computing/eks-multi-arch/"
11+
# Link to the next learning path being recommended.
12+
13+
14+
# further_reading links to references related to this path. Can be:
15+
# Manuals for a tool / software mentioned (type: documentation)
16+
# Blog about related topics (type: blog)
17+
# General online references (type: website)
18+
19+
further_reading:
20+
- resource:
21+
title: Run multiple processes in a container
22+
link: https://docs.docker.com/config/containers/multi-service_container/
23+
type: documentation
24+
- resource:
25+
title: Supervisor with Docker Lessons learned
26+
link: https://advancedweb.hu/supervisor-with-docker-lessons-learned/
27+
type: blog
28+
- resource:
29+
title: Multiple services in a Docker container with supervisord
30+
link: https://dev.to/pratapkute/multiple-services-in-a-docker-container-with-supervisord-2g13
31+
type: blog
32+
33+
34+
# ================================================================================
35+
# FIXED, DO NOT MODIFY
36+
# ================================================================================
37+
weight: 21 # set to always be larger than the content in this path, and one more than 'review'
38+
title: "Next Steps" # Always the same
39+
layout: "learningpathall" # All files under learning paths have this same wrapper
40+
---
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# ================================================================================
3+
# Edit
4+
# ================================================================================
5+
6+
# Always 3 questions. Should try to test the reader's knowledge, and reinforce the key points you want them to remember.
7+
# question: A one sentence question
8+
# answers: The correct answers (from 2-4 answer options only). Should be surrounded by quotes.
9+
# correct_answer: An integer indicating what answer is correct (index starts from 0)
10+
# explanation: A short (1-3 sentence) explanation of why the correct answer is correct. Can add additional context if desired
11+
12+
13+
review:
14+
- questions:
15+
question: >
16+
Is it possible to start multiple services in a container?
17+
answers:
18+
- "Yes"
19+
- "No"
20+
correct_answer: 1
21+
explanation: >
22+
You can use Supervisor, a process control system, to start multiple services in a container.
23+
24+
- questions:
25+
question: >
26+
You must open a port to be able to reach a running container using SSH.
27+
answers:
28+
- "True"
29+
- "False"
30+
correct_answer: 2
31+
explanation: >
32+
You can reach a local container using docker exec and a remote container using Remote.It. There are other services to each containers, but Remote.It is a good example of how to do it.
33+
34+
35+
# ================================================================================
36+
# FIXED, DO NOT MODIFY
37+
# ================================================================================
38+
title: "Review" # Always the same title
39+
weight: 20 # Set to always be larger than the content in this path
40+
layout: "learningpathall" # All files under learning paths have this same wrapper
41+
---
Loading
Loading
Loading
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
# User change
3+
title: "Install Supervisor, SSH, and Remote.It"
4+
weight: 3
5+
6+
layout: "learningpathall"
7+
8+
---
9+
10+
You can update the container to install Supervisor and create a container with multiple services.
11+
12+
The `Dockerfile` below includes some extra software for debug and test.
13+
14+
Here are the changes:
15+
- Install SSH and enable password login
16+
- Install and configure Remote.It
17+
- Add a Supervisor configuration file
18+
19+
Use a text editor to replace your `Dockerfile` with the new file below:
20+
21+
```console
22+
FROM ubuntu:22.04
23+
24+
RUN apt-get update && apt-get install -y curl iproute2 sudo openssh-server sudo vim apache2 supervisor procps uuid-runtime
25+
26+
# Configure SSH for password login
27+
RUN mkdir -p /var/run/sshd
28+
RUN sed -i '/PasswordAuthentication no/c\PasswordAuthentication yes' /etc/ssh/sshd_config
29+
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
30+
31+
# Configure Remote.It
32+
RUN mkdir -p /etc/remoteit
33+
RUN touch /etc/remoteit/registration
34+
RUN sh -c "$(curl -L https://downloads.remote.it/remoteit/install_agent.sh)"
35+
36+
# Configure Supervisor
37+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
38+
39+
# Setup default user
40+
RUN useradd --create-home -s /bin/bash -m ubuntu && echo "ubuntu:ubuntu" | chpasswd && adduser ubuntu sudo
41+
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
42+
43+
EXPOSE 80
44+
CMD ["/usr/bin/supervisord"]
45+
```
46+
47+
You will also need a configuration file for Supervisor.
48+
49+
Use a text editor to create a file named `supervisord.conf` with the contents:
50+
51+
```console
52+
[supervisord]
53+
user=root
54+
nodaemon=true
55+
logfile = /var/log/supervisord.log
56+
pidfile=/var/run/supervisord.pid
57+
58+
[program:sshd]
59+
command=/usr/sbin/sshd -D
60+
61+
[program:remoteit-agent]
62+
command=/usr/share/remoteit/refresh.sh
63+
64+
[program:apache2]
65+
command=/usr/sbin/apache2ctl -DFOREGROUND
66+
```
67+
68+
Build the container using:
69+
70+
```console
71+
docker build -t supervisord-dev .
72+
```
73+
74+
Before running the container you need a registration code from Remote.It.
75+
76+
Log in to your account at https://app.remote.it
77+
78+
From the dashboard click the + icon and select the Linux icon to add a new device.
79+
80+
Copy the generated registration code by clicking the bar code symbol under COPY as shown below:
81+
82+
![Registration code #center](remoteit-code.png)
83+
84+
With this code you can launch the container. Substitute your registration code instead of the one shown:
85+
86+
```console
87+
docker run -d -e R3_REGISTRATION_CODE=416ED829-D9D8-532C-B1FE-13548929B2A1 -p 80:80 supervisord-dev
88+
```
89+
90+
Once the container starts on your local machine you can open your browser to [https://localhost](http://localhost) and see the Apache welcome screen.
91+
92+
You will also see the device in your Remote.It dashboard.
93+
94+
In the dashboard, start the SSH connection by clicking the CONNECT bar as shown below:
95+
96+
![Connect #center](connect.png)
97+
98+
Once connected, get the values for the PUBLIC ENDPOINT
99+
100+
![Public endpoint #center](endpoint.png)
101+
102+
You can now SSH directly into the container. The username for the container is `ubuntu` and the password is also `ubuntu`. If desired, you can change this in the Dockerfile.
103+
104+
Change to your endpoint values in the command below to SSH:
105+
106+
```console
107+
ssh ssh://[email protected]:32443
108+
```
109+
110+
You are now inside the container as the `ubuntu` user.
111+
112+
Notice the SSH port was not shared by the container.
113+
114+
115+
116+
117+
118+
119+
120+

0 commit comments

Comments
 (0)