Search

ECR

resource "aws_ecr_repository" "customer" { name = "customer-ecr" image_scanning_configuration { scan_on_push = true } tags = { Name = "customer-ecr" } } resource "aws_ecr_repository" "product" { name = "product-ecr" image_scanning_configuration { scan_on_push = true } tags = { Name = "product-ecr" } } resource "aws_ecr_repository" "order" { name = "order-ecr" image_scanning_configuration { scan_on_push = true } tags = { Name = "order-ecr" } } output "customer_ecr" { value = aws_ecr_repository.customer.id } output "product_ecr" { value = aws_ecr_repository.product.id } output "order_ecr" { value = aws_ecr_repository.order.id }
JSON
복사
FROM alpine # ENV MYSQL_USER=<USERNAME> # ENV MYSQL_PASSWORD=<PASSWORD> # ENV MYSQL_HOST=<RDS_EP> # ENV MYSQL_PORT=<PORT> # ENV MYSQL_DBNAME=dev WORKDIR /app COPY ./customer /app/customer RUN apk update && \ apk add --no-cache libc6-compat libstdc++ libgcc curl openssl && \ apk upgrade --no-cache busybox && \ chmod +x /app/customer && \ adduser -D -H -s /bin/sh customer && \ mkdir -p /log/ && \ chown customer:customer /log USER customer EXPOSE 8080 CMD ["/bin/sh", "-c", "/app/customer >> /log/customer.log 2>&1"]
Docker
복사
FROM alpine # ENV MYSQL_USER=<USERNAME> # ENV MYSQL_PASSWORD=<PASSWORD> # ENV MYSQL_HOST=<RDS_EP> # ENV MYSQL_PORT=<PORT> # ENV MYSQL_DBNAME=dev WORKDIR /app COPY ./product /app/product RUN apk update && \ apk add --no-cache libc6-compat libstdc++ libgcc curl openssl && \ apk upgrade --no-cache busybox && \ chmod +x /app/product && \ adduser -D -H -s /bin/sh product && \ mkdir -p /log/ && \ chown product:product /log USER product EXPOSE 8080 CMD ["/bin/sh", "-c", "/app/product >> /log/product.log 2>&1"]
Docker
복사
FROM alpine WORKDIR /app COPY ./order /app/order RUN apk update && \ apk add --no-cache libc6-compat libstdc++ libgcc curl openssl && \ apk upgrade --no-cache busybox && \ chmod +x /app/order && \ adduser -D -H -s /bin/sh order && \ mkdir -p /log/ && \ chown order:order /log USER order EXPOSE 8080 CMD ["/bin/sh", "-c", "/app/order >> /log/order.log 2>&1"]
Docker
복사
#!/bin/bash ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) REGION_CODE=$(aws configure set region ap-northeast-2 && aws configure get region) IMAGE_NAME=("customer" "product" "order") for name in "${IMAGE_NAME[@]}" do aws ecr get-login-password --region $REGION_CODE | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com docker build -t $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/$name-ecr:latest ./$name/ docker push $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/$name-ecr:latest done
Shell
복사