ubuntu@ip-172-26-8-54:~/jenkins$ ll
total 24
drwxrwxr-x 3 ubuntu ubuntu 4096 Aug 5 05:42 ./
drwxr-xr-x 12 ubuntu ubuntu 4096 Aug 5 06:15 ../
-rw-rw-r-- 1 ubuntu ubuntu 356 Aug 1 16:23 Dockerfile
-rw-rw-r-- 1 ubuntu ubuntu 359 Aug 5 05:39 docker-compose.yml
-rw-rw-r-- 1 ubuntu ubuntu 476 Aug 1 16:24 docker_install.sh
drwxr-xr-x 12 root root 4096 Aug 5 05:59 jenkins_home/
#!/bin/sh
apt-get update && \\
apt-get -y install apt-transport-https \\
ca-certificates \\
curl \\
gnupg2 \\
zip \\
unzip \\
software-properties-common && \\
curl -fsSL <https://download.docker.com/linux/$>(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \\
add-apt-repository \\
"deb [arch=amd64] <https://download.docker.com/linux/$>(. /etc/os-release; echo "$ID") \\
$(lsb_release -cs) \\
stable" && \\
apt-get update && \\
apt-get -y install docker-ce
/etc/nginx/sites-available/muntopia.com
server {
server_name i7d209.p.ssafy.io;
root /jenkins/workspace/mungtopia/frontend/dist;
index index.html;
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/i7d209.p.ssafy.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/i7d209.p.ssafy.io/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location /jenkins {
rewrite ^ <http://i7d209.p.ssafy.io:9090>;
}
}
server {
if ($host = i7d209.p.ssafy.io) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name i7d209.p.ssafy.io;
return 404; # managed by Certbot
}
version: "3.1"
services:
jenkins:
restart: always
container_name: jenkins_d209
build:
dockerfile: Dockerfile
context: ./
user: root
ports:
- "9090:8080"
- "50000:50000"
volumes:
- ./jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
environment:
TZ: "Asia/Seoul"
FROM jenkins/jenkins:jdk11
#도커를 실행하기 위한 root 계정으로 전환
USER root
#도커 설치
COPY docker_install.sh /docker_install.sh
RUN chmod +x /docker_install.sh
RUN /docker_install.sh
#설치 후 도커그룹의 jenkins 계정 생성 후 해당 계정으로 변경
RUN groupadd -f docker
RUN usermod -aG docker jenkins
USER jenkins
node {
stage ('clone') {
git branch: 'develop', credentialsId: '64088bde-c635-4730-8b12-44e79dfb3c70', url: '<https://lab.ssafy.com/s07-webmobile1-sub2/S07P12D209.git>'
}
stage ('gradle build') {
dir('backend'){
sh 'chmod +x gradlew'
sh './gradlew build'
}
}
stage ('docker build') {
sh 'pwd'
sh 'docker-compose down'
sh 'docker-compose up -d --build'
sh 'docker rmi $(docker images -f "dangling=true" -q)'
}
}
# 프로젝트 Root 폴더
# 프로젝트Root/docker-compose.yml
version: '3.7'
services:
frontend:
restart: always
container_name: "mungtopia_frontend"
image: mungtopia_frontend:0.1
build:
context: frontend/
dockerfile: Dockerfile
ports:
- "3000:80"
# [인증서 파일 저장 경로]:/var/www/html
volumes:
- /etc/letsencrypt/live/i7d209.p.ssafy.io/:/var/www/html
environment:
- TZ=Asia/Seoul
backend:
container_name: "mungtopia_backend"
image: mungtopia_backend:0.1
build:
context: backend/
dockerfile: Dockerfile
ports:
- "8081:8081"
# [인증서 파일 저장 경로]:/root
volumes:
- /etc/letsencrypt/live/i7d209.p.ssafy.io/:/root
environment:
- TZ=Asia/Seoul