Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Containers on AWS: slides from the event with S...

Containers on AWS: slides from the event with Steamhaus and AWS

Steamhaus’ slides on the topic of building and running containers architectures on AWS.

Steamhaus

July 04, 2019
Tweet

More Decks by Steamhaus

Other Decks in Technology

Transcript

  1. ABOUT ME Chris Merrett • Co-founder and lead cloud architect

    at steamhaus • Based in manchester • 16 years industry experience
  2. My Talk Today Containers on AWS – Best Practices •

    Best practices for building container images • Information and advice REGARDING ECS • Information and advice REGARDING EKS • Which service should I pick to run my containers?
  3. CONTAINERS - best practices # Here, our initial stage is

    for builds and compilation # We're using one of our stable OS builds as the base FROM acmecorp/acmeos:stable as build # Accept a build argument, in this case the content of our selected # private key as some our dependencies are in private repos ARG SSH_PRIV_KEY # Authorize SSH Host RUN mkdir -p /root/.ssh && \ chmod 700 /root/.ssh && \ ssh-keyscan github.com > /root/.ssh/known_hosts # Add the key and set permissions # We don't want any trace of this in our final image! RUN echo "$SSH_PRIV_KEY" > /root/.ssh/id_rsa && \ chmod 600 /root/.ssh/id_rsa COPY . /app WORKDIR /app # This will be able to successfully pull our dependencies from private repos # due to the presence of our private key RUN composer install --working-dir=/app --no-dev --prefer-dist --optimize-autoloader # Our final stage is a CLEAN environment born of our stable OS image FROM acmecorp/acmeos:stable as final # Here we copy our artifact from our build layer. The SSH key and everything # else we did in the previous layer is left behind COPY --from=build /app /app # DO OTHER STUFF # Avoid using root RUN chown -R www-data: /app USER www-data EXPOSE 9000 CMD ["php-fpm", "-F", "-R"]
  4. CONTAINERS - best practices $ docker build --compress -t my-app:latest

    --build-arg \ SSH_PRIV_KEY="$(cat ~/.ssh/dependancies_id_rsa)" .