module "ec2_gitlab" {
source = "terraform-aws-modules/ec2-instance/aws"
name = "yusa-gitlab"
ami="${Amazone Linux 2 ami id}"
instance_type = "${instance type}"
key_name = "${private key which u already made}"
monitoring = false
associate_public_ip_address = true
vpc_security_group_ids = ["${SG id}"]
subnet_id = "${subnet id}"
ebs_block_device = [
{
device_name = "/dev/xvda"
volume_type = "gp2"
volume_size = 50
delete_on_termination = false
}
]
tags = data.aws_default_tags.aws_dt.tags
}
# The public IP address assigned to the instance, if applicable. NOTE: If you are using an aws_eip with your instance,
# you should refer to the EIP's address directly and not use public_ip as this field will change after the EIP is attached
resource "aws_eip" "yusa-gitlab-ip" {
instance = module.ec2_gitlab.id
}
sudo amazon-linux-extras install -y docker
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
sudo chmod 666 /var/run/docker.sock
docker info
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose -v
docker-compose version 1.27.4, build 40524192
sudo dpkg -i ./containerd.io_1.2.13-2_amd64.deb \
./docker-ce_19.03.103-0ubuntu-focal_amd64.deb \
./docker-ce-cli_19.03.103-0ubuntu-focal_amd64.deb \
./docker-buildx-plugin_0.10.2-1ubuntu.20.04focal_amd64.deb \
./docker-compose-plugin_2.10.2~ubuntu-focal_amd64.deb
이미지 확인
https://hub.docker.com/r/gitlab/gitlab-ce/
docker pull gitlab/gitlab-ce:latest
docker images
cd $HOME
mkdir gitlab
cd gitlab
mkdir config
mkdir logs
mkdir data
version: '3.6'
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab
restart: always
hostname: '${ec2 hostname}'
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://${gitlab EIP}'
ports:
- "${외부접속 포워딩할 포트, 해당포트가 SG에 allow일 것}:80"
- "${외부접속 포워딩할 포트, 해당포트가 SG에 allow일 것}:22"
- "${외부접속 포워딩할 포트, 해당포트가 SG에 allow일 것}:443"
volumes:
- '$HOME/gitlab/config:/etc/gitlab'
- '$HOME/gitlab/logs:/var/log/gitlab'
- '$HOME/gitlab/data:/var/opt/gitlab'
docker-compose up -d
docker logs -f gitlab
docker exec -it gitlab /bin/bash
cat /etc/gitlab/initial_root_password
Password: ~~~~~ 부분 복사해서, 비밀번호를 변경하는 것이 베스트~
selfsigned ca로 설정하려고하다가 하도 안되서 그냥... http로 해버렸다...
프로필 클릭
Password클릭 후 변경
git remote add origin ${깃주소:port}
git branch -M main
git push -uf origin main
git add .
git commit -m "first commit"
이제 테라폼을 관리할수있게 되었다!
기본적인 커맨드 https://victorydntmd.tistory.com/53
ssh-keygente
스택오버플로우나 다른곳에서도 찾아지지않음
그냥 멈춰버린다 ㅠㅠ
IP변경
https://jybaek.tistory.com/562
AWS Linux 2 Gitlab Community Edition 구축
https://nulls.co.kr/bones-skins/450
https://techviewleo.com/install-gitlab-ce-on-amazon-linux-with-lets-encrypt/
https://gksdudrb922.tistory.com/214
초기비밀번호 찾기
https://angellapgm.tistory.com/86
docker-compose 설치
https://deoking.tistory.com/9
브랜치 오류 해결
https://www.freecodecamp.org/news/error-src-refspec-master-does-not-match-any-how-to-fix-in-git/