diff --git a/Dockerfile b/Dockerfile index c5070e04..4427c2de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ -# Use an official Python runtime as the base image -FROM debian:11-slim AS build +ARG registry=942286566325.dkr.ecr.eu-west-1.amazonaws.com +FROM ${registry}/figshare/debian:11 AS build +LABEL org.opencontainers.image.source https://github.com/figshare/user_documentation # Set the working directory in the container WORKDIR /app @@ -33,6 +34,7 @@ RUN make swagger_install FROM build as development # Make the swagger documentation +RUN make build RUN make swagger_build # Expose port 8000 for the server @@ -40,3 +42,8 @@ EXPOSE 8000 # Set the default command to run when the container starts CMD ["make", "server"] + +FROM ${registry}/figshare/nginx:1.18 AS deployment + +# Copy the built documentation from the build stage +COPY --from=development /app /app diff --git a/Makefile b/Makefile index eb93e4e5..719fd386 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,11 @@ +DOCKER_EXE:=docker +DOCKER_BUILD_EXTRA_PARAMS:= +DOCKER_BUILD_PARAMS:=--ssh default --build-arg "DEPHASH=${DEPHASH}" ${DOCKER_BUILD_EXTRA_PARAMS} +TESTS_CONTAINER_NAME:=tests.user_documentation +CIMAGE_DEPLOYMENT_TAG:=figshare/user_documentation:deployment +CIMAGE_LATEST_TAG:=figshare/user_documentation:latest +CONFIGS_DIR:=./auto/configs + build: mkdocs build .PHONY: build @@ -26,12 +34,13 @@ swagger_install: cd swagger_documentation && make install .PHONY: swagger_install -container_images: - docker build --target build -t figshare/user_documentation:build . - docker build -t figshare/user_documentation:latest . -.PHONY: container_images +container-images: + ${DOCKER_EXE} build ${DOCKER_BUILD_PARAMS} --target build -t figshare/user_documentation:build . + ${DOCKER_EXE} build ${DOCKER_BUILD_PARAMS} --target development -t ${CIMAGE_LATEST_TAG} . + ${DOCKER_EXE} build ${DOCKER_BUILD_PARAMS} --target deployment -t ${CIMAGE_DEPLOYMENT_TAG} . +.PHONY: container-images container_build: - docker run --rm -v $(PWD):/app figshare/user_documentation:build make build - docker run --rm -v $(PWD):/app figshare/user_documentation:build make swagger_build + ${DOCKER_EXE} run --rm -v $(PWD):/app figshare/user_documentation:build make build + ${DOCKER_EXE} run --rm -v $(PWD):/app figshare/user_documentation:build make swagger_build .PHONY: container_build