오라클 자동화 더더 간단하게
https://svrforum.com/cloud/319909
위 글에서 tf 파일과 pem 키를 받으면 다음과 같이 Dockerfile을 이용할 수 있습니다.
FROM alpine:latest ENV SLEEP 60 RUN apk update && apk add terraform bash VOLUME [ "/data" ] WORKDIR /data CMD bash -c "terraform init; terraform plan -out=main.plan; while !(terraform apply -auto-approve main.plan); do sleep ${SLEEP}; done"
그리고 크레덴셜 설정정보는 ~/.oci/config 또는 원하는 위치에, pem 키는 기본 ~/.ssh/oci.pem 과 같이 위치하고 다음 compose 파일을 사용합니다.
services: oci-free: build: . container_name: oci-free volumes: - ./data:/data - ~/.oci:/root/.oci - ~/.ssh:/root/.ssh networks: - local environment: - SLEEP=10 networks: local: external: true
그러면 자동으로 제공된 SLEEP 시간만큼 기다렸다가 성공할 때까지 반복 수행을 하게 됩니다. 로그는 따로 안빼고 docker logs --follow oci-free 명령으로 tail 처럼 사용하는데, 성공하면 어차피 컨테이너가 정상 종료되어야 하므로... 볼 일이 있을까 모르겠네요.
cmt alert