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?
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"]