ECS: aws-cli

  • curl, unzip は入っていること
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
ARG BASE_IMAGE=myimage-cicd-appbase
ARG TAG=latest

FROM ${BASE_IMAGE}:${TAG} as server

ARG USERNAME=ubuntu
ARG GROUPNAME=ubuntu
ARG PASSWORD=ubuntu
ARG UID=1000
ARG GID=1000

ENV APP_BASE=/usr/src/app \
    LIB_BASE=/usr/src/lib \
    POETRY_VERSION=1.0.10 \
    PATH="/root/.poetry/bin:$PATH"

RUN mkdir -p /var/run/gunicorn && mkdir -p /storage
RUN apt-get update && apt-get install -y sudo

RUN groupadd -g ${GID} ${GROUPNAME} && \
    useradd -m -s /bin/bash -u ${UID} -g ${GID} -G sudo ${USERNAME} --home-dir ${APP_BASE} && \
    echo ${USERNAME}:${PASSWORD} | chpasswd && \
    echo "${USERNAME}   ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# aws-cli
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
RUN unzip awscliv2.zip
RUN sudo ./aws/install

# Application
COPY . ${APP_BASE}
WORKDIR ${APP_BASE}

RUN pip install pip poetry urllib3==1.26.15 -U && \
    poetry config virtualenvs.create false  && \
    poetry install && pip install urllib3==1.26.15 pyOpenSSL -U

RUN chown -R ${USERNAME}:${GROUPNAME} ${APP_BASE}
RUN chmod 777 /run/gunicorn
USER ${USERNAME}

CMD ["/usr/src/app/docker/codebuild/entry_web.sh", "/usr/src/app"]