Jenkins
1. git clone
2. gradle build
3. .jar ssh publisher
aws api-server로 .jar 파일 복사
4. ansible playbook 실행
aws ansible-server ssh접속 후 playbook실행 (api-server 도커 제어)
Dockerfile
FROM openjdk:17-alpine
VOLUME /tmp
ARG JAR_FILE=./*.jar
COPY ./airbnbApi-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","-Djasypt.encryptor.password=djswpsrksms","/app.jar"]
Playbook.yml
- hosts: all
# become: true
tasks:
- name: stop current running container
command: docker stop airbnb-demo
ignore_errors: yes
- name: remove stopped cotainer
command: docker rm airbnb-demo
ignore_errors: yes
- name: remove current docker image
command: docker rmi api-v1
ignore_errors: yes
- name: build a docker image with deployed war file
command: docker build -t api-v1 .
args:
chdir: /root
- name: create a container using image
command: docker run -d --name airbnb-demo -p 8081:8080 api-v1