diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..e9ff2bac --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +# Files to exclude from COPY and ADD commands when +# building a docker image from this directory + +# Exclude Docker build related files +Dockerfile +.dockerignore + +# Exclude the git directory and gitignore file +.git +.gitignore + +# Skip any existing logs +log/* + +# Skip LICENSE, README, etc. +LICENSE +*.md + +# Skip pipenv/virtualenv related things +.envrc +.venv + +# Skip ansible-container stuff +ansible* +container.yml +meta.yml +requirements.yml diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile new file mode 100644 index 00000000..44aa4791 --- /dev/null +++ b/docker/prod/Dockerfile @@ -0,0 +1,40 @@ +FROM python:3.6.5-alpine + +# Overridable default config +ARG APP_USER=atst +ARG APP_GROUP=atat +ARG APP_DIR=/opt/atat/atst +ARG APP_PORT=8000 +ARG SITE_PACKAGES_DIR=/usr/local/lib/python3.6/site-packages + +ENV APP_DIR "${APP_DIR}" +ENV SKIP_PIPENV true + +# Copy installed python packages from the tester image +COPY --from=atst-tester:latest "${SITE_PACKAGES_DIR}" "${SITE_PACKAGES_DIR}" + +# Copy the app directory contents from the tester image (includes node modules) +COPY --from=atst-tester:latest "${APP_DIR}" "${APP_DIR}" + +# Set working dir +WORKDIR ${APP_DIR} + +# Add required system packages and app user +RUN set -x ; \ + script/alpine_setup "${APP_USER}" "${APP_GROUP}" + +# Update file ownership +RUN set -x ; \ + chown -R atst:atat "${APP_DIR}" + +# Set port to open +EXPOSE "${APP_PORT}" + +# Run as the unprivileged APP user +USER "${APP_USER}" + +# Use dumb-init for proper signal handling +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +# Default command is to launch the server +CMD ["bash", "-c", "${APP_DIR}/script/server"] diff --git a/docker/tester/Dockerfile b/docker/tester/Dockerfile new file mode 100644 index 00000000..618371fb --- /dev/null +++ b/docker/tester/Dockerfile @@ -0,0 +1,32 @@ +FROM atat-app-builder-builder:latest as app-builder + +ARG APP_USER=atst +ARG APP_GROUP=atat +ARG APP_DIR=/opt/atat/atst +ARG CIBUILD=true + +ENV SKIP_PIPENV true + +# Create application directory +RUN set -x ; \ + mkdir -p ${APP_DIR} + +# Set working dir +WORKDIR ${APP_DIR} + +# Copy app and module files +COPY . . + +# Add required system packages and app user +RUN set -x ; \ + script/alpine_setup "${APP_USER}" "${APP_GROUP}" + +# Install app dependencies +RUN set -x ; \ + script/setup + +# Use dumb-init for proper signal handling +ENTRYPOINT ["/usr/bin/dumb-init", "--"] + +# Default command is to run all the tests +CMD ["${APP_DIR}/script/cibuild"]