Last active
November 12, 2018 15:36
-
-
Save mrgleeco/cc75347baaf9471b477ba9830bbefc06 to your computer and use it in GitHub Desktop.
Revisions
-
mrgleeco revised this gist
Nov 12, 2018 . 1 changed file with 30 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ ## create a single unified service container that runs nginx AND app upstream # --------- # if used as a later stage, use this: # FROM app # otherwise, lets make as a dedicated image bundle that is rebuilt with app as dep layer FROM us.gcr.io/my-project/my-app USER root:root RUN apt-get update && apt-get install -y \ nginx \ supervisor && \ apt-get autoremove --yes && \ apt-get autoclean && \ rm -rf /var/lib/apt/lists/* RUN echo "daemon off;" >> /etc/nginx/nginx.conf RUN pip install \ supervisor-stdout \ uwsgi RUN groupadd -g 999 app && useradd -r -u 999 -g app app # you are responsible for tuning these bits! COPY my-app/etc/uwsgi.ini /app/uwsgi.ini COPY my-app/etc/app.nginx.conf /etc/nginx/sites-enabled/app.conf COPY my-app/etc/supervisor-app.conf /etc/supervisor/conf.d/ EXPOSE 8080 CMD ["supervisord", "-n"] -
mrgleeco created this gist
Nov 12, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,54 @@ ## NOTE: multi-stage builds require docker ce > 17 ## NOTE: grep for myapp or my-app here as placeholders FROM python:2.7-slim-stretch as app-base # here install some basics you might want need RUN apt-get update && \ apt-get upgrade --yes && \ apt-get install --yes \ git \ curl \ vim-tiny && \ apt-get --purge remove --yes \ manpages \ manpages-dev && \ apt-get autoremove --yes && \ apt-get autoclean && \ rm -rf /var/lib/apt/lists/* ## next layer is all the python FROM app-base as app-python RUN mkdir -p /src /opt/python WORKDIR /src COPY . /src RUN pip install --prefix=/opt/python -r /src/requirements.txt RUN pip --no-cache-dir install --prefix=/opt/python . ## Final layer has any final bits like adduser or system tweaks FROM app-base as ap MAINTAINER USER <[email protected]> ARG RELEASE_VERSION ARG BUILD_DATE ARG VCS_REF LABEL \ org.label-schema.build-date=$BUILD_DATE \ org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/my-org/my-repo" ENV REFRESHED_AT=${BUILD_DATE} \ RELEASE_VERSION=${RELEASE_VERSION} \ VCS_REF=${VCS_REF} COPY docker-entrypoint.sh / # copy as late as possible COPY --from=app-python /opt/python /usr/local ENTRYPOINT ["/docker-entrypoint.sh"] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ # NOTE: grep for myapp or my-app here as placeholders SHELL=/bin/bash DOCKER_IMG := us.gcr.io/my-project/my-app TDATE := $(shell date -u +"%Y-%m-%dT%H:%M:%S%z") VCS_REF := $(shell git rev-parse --short HEAD) APPLIB_VERSION := $(shell python -c 'import myapp.__version__ as v; print v.__version__') RELEASE_VERSION := $(APPLIB_VERSION)-$(VCS_REF) .PHONY: build # full container build build: docker build \ --build-arg VCS_REF=$(VCS_REF) \ --build-arg BUILD_DATE=$(TDATE) \ --build-arg RELEASE_VERSION=$(RELEASE_VERSION) \ . -t $(DOCKER_IMG):$(RELEASE_VERSION) .PHONY: push # Push official release container push: docker push $(DOCKER_IMG):$(RELEASE_VERSION) .PHONY: push-latest # Push official release container push-latest: push docker tag $(DOCKER_IMG):$(RELEASE_VERSION) $(DOCKER_IMG):latest docker push $(DOCKER_IMG):latest