python flask return index.html
FROM ubuntu:latest
WORKDIR /app
COPY ./app.py .
COPY ./index.html ./templates/
RUN apt update -y
RUN apt install -y curl
RUN apt install -y python3-pip
RUN pip3 install flask
RUN python3 -m compileall ./app.py
RUN mv ./__pycache__/*.pyc ./app.pyc
RUN useradd skills
USER skills
EXPOSE 8080
CMD ["python3", "app.pyc"]
#1 dockerfile 생성
#2 build dockerfile image & image start
docker build -t <image name> .
docker run -d -p 8080:8080 <image name>
#3 container 접근 및 값 출력 확인
docker ps #docker container id 확인
docker exec -it <container id> bash
#4 ECR 생성
#5 push docker iamge ECR
Push 명령어에서 뒤 tag를 변경한다
2 Visual Studio Code에서 폴더 하나를 생성한뒤
time=$(date -d "-9 hours" "+%Y.%m.%s.%H.%M.%S")
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.ap-northeast-2.amazonaws.com
docker build -t $ECR_name .
docker tag $ECR_name:latest $ACCOUNT_ID.dkr.ecr.ap-northeast-2.amazonaws.com/$ECR_name:$time
docker push $ACCOUNT_ID.dkr.ecr.ap-northeast-2.amazonaws.com/$ECR_name:$time
#위의 시간은 서울 시간 linux 시간 보고 설정해야 함 -9
리눅스 시간 확인 date