2023. 11. 28. 16:51ㆍ🧑🏻💻/42
ec2 instance에서 진행 절차
0. inception subject 정독
1. subject요구 사항 리스트업
- Container: NGINX with TLSv1.3 only.
- Container: WordPress + php-fpm (it must be installed and configured) only without nginx.
- Container: MariaDB only without nginx.
- Volume: WordPress database.
- Volume: WordPress website files.
- A docker-network that establishes the connection between my containers.
- Makefile
$> ls -alR
total XX
drwxrwxr-x 3 wil wil 4096 avril 42 20:42 .
drwxrwxrwt 17 wil wil 4096 avril 42 20:42 ..
-rw-rw-r-- 1 wil wil XXXX avril 42 20:42 Makefile
drwxrwxr-x 3 wil wil 4096 avril 42 20:42 srcs
./srcs:
total XX
drwxrwxr-x 3 wil wil 4096 avril 42 20:42 .
drwxrwxr-x 3 wil wil 4096 avril 42 20:42 ..
-rw-rw-r-- 1 wil wil XXXX avril 42 20:42 docker-compose.yml
-rw-rw-r-- 1 wil wil XXXX avril 42 20:42 .env
drwxrwxr-x 5 wil wil 4096 avril 42 20:42 requirements
./srcs/requirements:
total XX
drwxrwxr-x 5 wil wil 4096 avril 42 20:42 .
drwxrwxr-x 3 wil wil 4096 avril 42 20:42 ..
drwxrwxr-x 4 wil wil 4096 avril 42 20:42 bonus
drwxrwxr-x 4 wil wil 4096 avril 42 20:42 mariadb
drwxrwxr-x 4 wil wil 4096 avril 42 20:42 nginx
drwxrwxr-x 4 wil wil 4096 avril 42 20:42 tools
drwxrwxr-x 4 wil wil 4096 avril 42 20:42 wordpress
./srcs/requirements/mariadb:
total XX
drwxrwxr-x 4 wil wil 4096 avril 42 20:45 .
drwxrwxr-x 5 wil wil 4096 avril 42 20:42 ..
drwxrwxr-x 2 wil wil 4096 avril 42 20:42 conf
-rw-rw-r-- 1 wil wil XXXX avril 42 20:42 Dockerfile
-rw-rw-r-- 1 wil wil XXXX avril 42 20:42 .dockerignore
drwxrwxr-x 2 wil wil 4096 avril 42 20:42 tools
[...]
./srcs/requirements/nginx:
total XX
drwxrwxr-x 4 wil wil 4096 avril 42 20:42 .
drwxrwxr-x 5 wil wil 4096 avril 42 20:42 ..
drwxrwxr-x 2 wil wil 4096 avril 42 20:42 conf
-rw-rw-r-- 1 wil wil XXXX avril 42 20:42 Dockerfile
-rw-rw-r-- 1 wil wil XXXX avril 42 20:42 .dockerignore
drwxrwxr-x 2 wil wil 4096 avril 42 20:42 tools
[...]
$> cat srcs/.env
DOMAIN_NAME=wil.42.fr
# certificates
CERTS_=./XXXXXXXXXXXX
# MYSQL SETUP
MYSQL_ROOT_PASSWORD=XXXXXXXXXXXX
MYSQL_USER=XXXXXXXXXXXX
MYSQL_PASSWORD=XXXXXXXXXXXX
[...]
$>
2. ec2 instance 생성
- Application and OS Images (Amazon Machine Image) : Ubuntu로 선택 (이유 : ssh / ufw 등 설치하지 않아도 됨.)
- 인스턴스 유형 t2.micro 사용 (프리 티어 선택)
- EBS 스토리지 30GiB
3. VSCode extension인 VSCode with remote ssh로 EC2 instance와 연결 (pem key 설정등 해줘야함)
Name: Remote - SSH
Id: ms-vscode-remote.remote-ssh
Description: Open any folder on a remote machine using SSH and take advantage of VS Code's full feature set.
Version: 0.107.1
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh
Remote - SSH - Visual Studio Marketplace
Extension for Visual Studio Code - Open any folder on a remote machine using SSH and take advantage of VS Code's full feature set.
marketplace.visualstudio.com
4. GUI환경을 위해서 ubuntu-desktop, xrdp, xfce4 를 설치합니다.
sudo apt-get update
sudo apt-get install ubuntu-desktop xrdp xfce4 xfce4-goodies
4-1. x 관련 설정을 해줍니다.
echo xfce4-session > ~/.xsession
sudo cp /home/ubuntu/.xsession /etc/skel
chmod a+x ~/.xsession
sudo sed -i '0,/-1/s//ask-1/' /etc/xrdp/xrdp.ini
sudo service xrdp restart
4-2. 인스턴스를 재부팅 해줍니다.
sudo reboot
4-3. 인스턴스가 탄력적 IP설정이 되어있지 않다면, 재부팅시에 ip주소가 변경 되었으므로 해당하는 주소로 다시 ssh 접근을 해야합니다. (3번을 다시 해줘야합니다.)
5. RDP로 GUI환경 세팅 후 진행 (CoRD 사용) / VNC도 사용해봤지만 생각처럼 GUI 환경이 제대로 이루어지지 않아서 가볍게 사용할 수 있는 RDP를 사용하게 되었습니다.
https://cord.sourceforge.net/
CoRD: Remote Desktop for Mac OS X
CoRD was a Mac OS X remote desktop client for Microsoft Windows computers using the RDP protocol. It's easy to use, fast, and free for anyone to use or modify. Announcements 2020-04-13: This project is defunct. Most people will be happy with Microsoft's cl
cord.sourceforge.net
5-1. 인스턴스 유형 t2.micro 사용 과정에서 프리티어를 사용하다가 GUI환경으로 접속이 불가능해서 제대로 이용하려면 t2 사양을 업그레이드해야 한 다는 것을 깨닫고 사양을 업그레이드하여 진행하였습니다. ㅠㅠ (t2.large)
5-2. CoRD가 자주 꺼지니 당황하지 마시고 꺼진다면 다시 켜서 접속하시면 됩니다.
6. Docker와 Docker Compose 설치
(https://docs.docker.com/engine/install/ubuntu/ && https://docs.docker.com/compose/install/linux/)
7. https://github.com/chanheki/Inception
GitHub - chanheki/Inception: docker compose
docker compose. Contribute to chanheki/Inception development by creating an account on GitHub.
github.com
'🧑🏻💻 > 42' 카테고리의 다른 글
클러스터 Mac에 Brew 다운로드 (0) | 2023.08.09 |
---|