diff --git a/Dockerfile.prd b/Dockerfile.prd new file mode 100644 index 00000000..ec2a458d --- /dev/null +++ b/Dockerfile.prd @@ -0,0 +1,51 @@ +FROM unicef/donor-reporting-portal-backend:0.6-base + +COPY . /code +WORKDIR /code +RUN pip3 install . \ + && rm -fr /code + +ENV PYTHONUNBUFFERED=1 +ENV DJANGO_SETTINGS_MODULE=donor_reporting_portal.config.settings +ENV SECRET_KEY="not-so-secret-key-just-for-collectstatic" +ENV STATIC_ROOT=/tmp/static +ENV MEDIA_ROOT=/tmp/media + +ENV UWSGI_PROTOCOL=http \ + UWSGI_WORKERS=4 \ + UWSGI_AUTO_PROCNAME=true \ + UWSGI_BUFFER_SIZE=32768 \ + UWSGI_DIE_ON_TERM=true \ + UWSGI_DISABLE_LOGGING=false \ + UWSGI_DISABLE_WRITE_EXCEPTION=true \ + UWSGI_FREEBIND=true \ + UWSGI_HARAKIRI=180 \ + UWSGI_HTTP_TIMEOUT=180 \ + UWSGI_IGNORE_SIGPIPE=true \ + UWSGI_IGNORE_WRITE_ERRORS=true \ + UWSGI_LIMIT_POST=20971520 \ + UWSGI_LOG_X_FORWARDED_FOR=false \ + UWSGI_MEMORY_REPORT=true \ + UWSGI_NEED_APP=true \ + UWSGI_POST_BUFFERING=65536 \ + UWSGI_PROCNAME_PREFIX_SPACED="[DonorReportingPortal]" \ + UWSGI_RELOAD_ON_RSS=600 \ + UWSGI_THREADS=4 \ + UWSGI_THUNDER_LOCK=true \ + UWSGI_VACUUM=true \ + UWSGI_MODULE="donor_reporting_portal.config.wsgi:application" \ + UWSGI_HTTP_SOCKET=0.0.0.0:8000 \ + UWSGI_MASTER=true \ + UWSGI_ENABLE_THREADS=true \ + UWSGI_LAZY_APPS=true \ + UWSGI_SINGLE_INTERPRETER=true + +EXPOSE 8000 + +ADD docker/*.sh /usr/local/bin/ + +ENTRYPOINT ["entrypoint.sh"] +RUN ["chmod", "+x", "/usr/local/bin/entrypoint.sh"] +WORKDIR /var/donor_reporting_portal + +CMD ["donor_reporting_portal"] diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..658d6f57 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,22 @@ +# Python Django +# Test a Django project on multiple versions of Python. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/python + +pool: + vmImage: 'ubuntu-16.04' + +variables: + imageName: '$(Build.BuildId)' + # define two more variables dockerId and dockerPassword in the build pipeline in UI + +steps: +- script: | + cd docker + make build + docker tag unicef/donor-reporting-portal-backend:${TARGET} unicef/donor-reporting-portal-backend:dev + docker push unicef/donor-reporting-portal-backend:${TARGET} + docker push unicef/donor-reporting-portal-backend:dev + env: + pswd: $(dockerPassword) + displayName: 'Build and push Docker image' diff --git a/docker/Dockerfile b/docker/Dockerfile index 7ebf0718..431bb5ca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ ARG BASE_IMAGE=0.6 -FROM unicef/donor-reporting-portal-backend:${BASE_IMAGE}-base +FROM unicef/donor-reporting-portal-backend:0.6-base #ARG BUILD_DATE #ARG VERSION diff --git a/docker/Makefile b/docker/Makefile index 09e232c5..7206b62a 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -8,9 +8,7 @@ BASE?=$(shell echo "${TARGET}" | sed "s/\([0-9]\)\.\([0-9]\)\.\(.*\)/\1.\2/g" ) BUILD_OPTIONS?= CMD?=donor_reporting_portal CONTAINER_NAME?=donor_reporting_portal-${TARGET} -ORGANIZATION=unicef -IMAGE_NAME=donor-reporting-portal-backend -DOCKER_IMAGE_NAME?=${ORGANIZATION}/${IMAGE_NAME} +DOCKER_IMAGE_NAME?=unicef/donor-reporting-portal-backend DOCKER_IMAGE?=${DOCKER_IMAGE_NAME}:${TARGET} DOCKERFILE?=Dockerfile RUN_OPTIONS?= @@ -48,7 +46,7 @@ build-test: TARGET=dev $(MAKE) .build test build: - $(MAKE) .build test + $(MAKE) .build .run: cd .. && docker run \ @@ -92,10 +90,8 @@ local: $(MAKE) .run release: - @echo ${DOCKER_PASS} | docker login -u ${DOCKER_USER} --password-stdin - docker tag ${DOCKER_IMAGE_NAME}:${TARGET} ${DOCKER_IMAGE_NAME}:dev + echo "${DOCKER_PASS}" | docker login -u "${DOCKER_USER}" --password-stdin docker push ${DOCKER_IMAGE_NAME}:${TARGET} - docker push ${DOCKER_IMAGE_NAME}:dev # deploy: # lazo rancher upgrade donor_reporting_portal:donor_reporting_portal ${DOCKER_IMAGE_NAME}:${TARGET}