Repository: AlertaDengue/AlertaDengue (language: python)

Issue:
Enable test-staging command call
## Geral / General

Makefile tries to run tests inside Docker from a outside test file.


Discussion / hints:

Fix patch:
diff --git a/Makefile b/Makefile
index 8d7ab102..5de1c655 100644
--- a/Makefile
+++ b/Makefile
@@ -70,16 +70,16 @@ django-static-geofiles:
 	$(DOCKER) run --rm web python3 manage.py sync_geofiles
 	$(DOCKER) run --rm web python3 manage.py collectstatic --noinput
 
-.PHONY:docker-restart
-test-infodengue-web:
-	$(DOCKER) run --no-deps web bash ../docker/test.sh dados
-	$(DOCKER) run --no-deps web bash ../docker/test.sh dbf
-	$(DOCKER) run --no-deps web bash ../docker/test.sh gis
-	$(DOCKER) run --no-deps web bash ../docker/test.sh api
-	#$(DOCKER) run --no-deps web bash ../docker/test.sh forecast
-
-.PHONY:test-infodengue-all
-test-infodengue-all:
+.PHONY:test-staging-web
+test-staging-web:
+	$(DOCKER) run --no-deps web bash /opt/services/test.sh dados
+	$(DOCKER) run --no-deps web bash /opt/services/test.sh dbf
+	$(DOCKER) run --no-deps web bash /opt/services/test.sh gis
+	$(DOCKER) run --no-deps web bash /opt/services/test.sh api
+	#$(DOCKER) run --no-deps web bash /opt/services/test.sh forecast
+
+.PHONY:test-staging-all
+test-staging-all:
 	$(DOCKER) run --rm web python3 manage.py test
 
 
diff --git a/docker/Dockerfile-base b/docker/Dockerfile-base
index 6d3f3d64..34b0a866 100644
--- a/docker/Dockerfile-base
+++ b/docker/Dockerfile-base
@@ -40,7 +40,6 @@ USER deploy
 ## Copy code to the container with permissions to user
 COPY --chown=deploy:deploy AlertaDengue  /opt/services/AlertaDengue
 COPY --chown=deploy env.tpl pyproject.toml poetry.lock  /opt/services/AlertaDengue/
-COPY --chown=deploy:deploy docker/entrypoint.sh /entrypoint.sh
 COPY --chown=deploy:deploy conda/environment.yaml /tmp/environment.yaml
 
 # Use environment to update the env alertadengue
@@ -53,5 +52,6 @@ RUN mamba env create -n $ENV_NAME \
   && find /opt/conda/ -type f,l -name '*.js.map' -delete \
   && rm -rf /opt/conda/pkgs
 
+COPY --chown=deploy:deploy docker/entrypoint.sh /entrypoint.sh
 WORKDIR /opt/services/AlertaDengue
 ENTRYPOINT ["bash", "/activate.sh"]
diff --git a/docker/Dockerfile-dev b/docker/Dockerfile-dev
index 9dfa603c..bda8827a 100644
--- a/docker/Dockerfile-dev
+++ b/docker/Dockerfile-dev
@@ -20,6 +20,9 @@ RUN echo 'source /opt/conda/bin/activate "$ENV_NAME" && exec "$@"' > /activate.s
 ENV PATH "$PATH:/home/deploy/.local/bin"
 ENV PATH /opt/conda/envs/$ENV_NAME/bin:$PATH
 
+COPY --chown=deploy:deploy docker/test.sh /opt/services
+RUN chmod +x /opt/services/test.sh
+
 USER deploy
 
 # Use environment to update the env alertadengue
@@ -33,3 +36,5 @@ RUN mamba env create -n $ENV_NAME \
   && rm -rf /opt/conda/pkgs
 
 # EXPOSE 8080
+
+CMD ["/opt/services/AlertaDengue/runwsgi.sh"]
diff --git a/docker/Dockerfile-web b/docker/Dockerfile-web
index 398f7902..e5c66986 100644
--- a/docker/Dockerfile-web
+++ b/docker/Dockerfile-web
@@ -16,3 +16,5 @@ RUN chmod 0644 /etc/cron.d/cron-tasks \
 USER deploy
 
 # EXPOSE 8000
+
+CMD ["/opt/services/AlertaDengue/runwsgi.sh"]
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index fd724505..60e3ac37 100755
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -4,5 +4,8 @@ echo "Create environment variables..."
 envsubst < /opt/services/AlertaDengue/env.tpl > /opt/services/AlertaDengue/.env
 echo "Start crontab..."
 sudo service cron start
-echo "Start django..."
-bash /opt/services/AlertaDengue/runwsgi.sh
+
+if [ $# -ne 0 ]
+  then
+    exec "$@"
+fi


Test patch:
diff --git a/docker/test.sh b/docker/test.sh
index bc7a6949..9ecb6b13 100755
--- a/docker/test.sh
+++ b/docker/test.sh
@@ -1,4 +1,4 @@
 #!/usr/bin/env bash
 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 cd ${current_dir}; cd ..
-env_file=".env_staging" AlertaDengue/manage.py test ${1}
+env_file=".env" /opt/services/AlertaDengue/manage.py test ${1}