AnubisLMS / AnubisLMS/Anubis

ADD insert commit hash into web and api images

Đang mở
#397 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
backend feature
Ngôn ngữ chính
Python
Star
381
Fork
53
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

# Putting commit in docker images

We can do this through the `GIT_TAG` environment variable from the makefile, that is passed to the docker-compose setup. We can add it as an environment variable. Pass this to the docker build by specifying it as a [docker build arg](https://docs.docker.com/engine/reference/builder/#arg) [in the docker-compose.yml file](https://docs.docker.com/compose/compose-file/build/#args). The `GIT_TAG` environment variable will be set when building through `make build`, so you can reference it in the docker compose file like this: `${GIT_TAG:-latest}`. This is a special way of referencing an environment variable, where if `GIT_TAG` is not set, it will default to `latest`.

You can make these environment variables available when the docker image builds by converting the build arg to [an environment variable](https://docs.docker.com/engine/reference/builder/#env).

For example:

```dockerfile
ARG GIT_TAG=latest # default to latest
ENV GIT_TAG=${GIT_TAG} # convert build arg value to environment variable
```

# Exposing in services

## api
Then expose it throught the [healthcheck endpoint](https://github.com/AnubisLMS/Anubis/blob/main/api/anubis/utils/healthcheck.py) on the api.

## web
Expose it in the [footer of the website](https://github.com/AnubisLMS/Anubis/blob/main/web/src/components/shared/Footer.jsx). For the react website, you can see how to use an environment variable like this here https://create-react-app.dev/docs/adding-custom-environment-variables/ (basically just add `REACT_APP_` before the environment variable)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.