Skip to content

Commit 124d49b

Browse files
committed
chore: don't use git to determine the commit hash
Get the commit hash from the openshift's environment.
1 parent db093d9 commit 124d49b

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ RUN yum update -y && yum install -y \
2222
&& uwsgi --build-plugin https://github.com/City-of-Helsinki/uwsgi-sentry \
2323
&& yum clean all
2424

25-
# fatal: detected dubious ownership in repository at '/app'
26-
RUN git config --system --add safe.directory /app
27-
2825
COPY --chown=root:root --chmod=755 docker-entrypoint.sh /entrypoint/docker-entrypoint.sh
2926
ENTRYPOINT ["/entrypoint/docker-entrypoint.sh"]
3027

@@ -46,4 +43,4 @@ FROM appbase AS production
4643
RUN SECRET_KEY="only-used-for-collectstatic" python manage.py collectstatic
4744

4845
USER default
49-
EXPOSE 8000/tcp
46+
EXPOSE 8000/tcp

common/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def update_object_with_translations(model, model_data):
8686

8787

8888
def get_api_version():
89-
return " | ".join((__version__, settings.COMMIT_HASH.decode("utf-8")))
89+
return " | ".join((__version__, settings.COMMIT_HASH))
9090

9191

9292
def get_node_id_from_global_id(global_id, node_name):

palvelutarjotin/settings.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.utils.translation import gettext_lazy as _
1111
from sentry_sdk.integrations.django import DjangoIntegration
1212

13+
from palvelutarjotin import __version__
1314
from palvelutarjotin.consts import CSP
1415

1516
checkout_dir = environ.Path(__file__) - 2
@@ -94,6 +95,7 @@
9495
SOCIAL_AUTH_TUNNISTAMO_SECRET=(str, ""), # empty to ignore it's being unset.
9596
LOGIN_REDIRECT_URL=(str, "/admin/"),
9697
LOGOUT_REDIRECT_URL=(str, "/admin/"),
98+
OPENSHIFT_BUILD_COMMIT=(str, ""),
9799
)
98100

99101
if os.path.exists(env_file):
@@ -163,9 +165,11 @@
163165
except Exception:
164166
COMMIT_HASH = b"n/a"
165167

168+
COMMIT_HASH = env("OPENSHIFT_BUILD_COMMIT")
169+
VERSION = __version__
166170
sentry_sdk.init(
167171
dsn=env.str("SENTRY_DSN"),
168-
release=COMMIT_HASH,
172+
release=env("OPENSHIFT_BUILD_COMMIT", VERSION),
169173
environment=env("SENTRY_ENVIRONMENT"),
170174
integrations=[DjangoIntegration()],
171175
)

palvelutarjotin/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def readiness(*args, **kwargs):
6464
"status": "ok",
6565
"release": settings.APP_RELEASE,
6666
"packageVersion": __version__,
67-
"commitHash": settings.COMMIT_HASH.decode("utf-8"),
67+
"commitHash": settings.COMMIT_HASH,
6868
"buildTime": settings.APP_BUILD_TIME.strftime("%Y-%m-%dT%H:%M:%S.000Z"),
6969
}
7070
return JsonResponse(response_json, status=200)

0 commit comments

Comments
 (0)