Skip to content

Commit

Permalink
Add git commit hash to client builds (#1107)
Browse files Browse the repository at this point in the history
* refactor some docker stuff to be more homogeneous

* add optional git commit to docker images client builds

* add git commit hash to Home and Room view's footers
  • Loading branch information
dyc3 authored Oct 13, 2023
1 parent 074d9bb commit 0713c75
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 deletions.
6 changes: 6 additions & 0 deletions client/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@
$t("footer.attribution")
}}</router-link>
</v-row>
<v-row no-gutters align="center" justify="center">
{{ gitCommit }}
</v-row>
</v-container>
</v-footer>
</v-container>
Expand All @@ -185,6 +188,8 @@ export const HomeView = defineComponent({
setup() {
const store = useStore();
const gitCommit = __COMMIT_HASH__;
async function createTempRoom() {
await createRoomHelper(store);
}
Expand All @@ -196,6 +201,7 @@ export const HomeView = defineComponent({
return {
createTempRoom,
cardHeight,
gitCommit,
};
},
});
Expand Down
6 changes: 6 additions & 0 deletions client/src/views/Room.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@
<v-row no-gutters align="center" justify="center">
<router-link to="/privacypolicy">{{ $t("footer.privacy-policy") }}</router-link>
</v-row>
<v-row no-gutters align="center" justify="center">
{{ gitCommit }}
</v-row>
</v-container>
</v-footer>
<v-overlay
Expand Down Expand Up @@ -651,6 +654,8 @@ export default defineComponent({
await sfx.loadSfx();
});
const gitCommit = __COMMIT_HASH__;
return {
store,
roomapi,
Expand Down Expand Up @@ -685,6 +690,7 @@ export default defineComponent({
production,
debugMode,
orientation: orientation.orientation,
gitCommit,
mediaPlaybackBlocked,
onClickUnblockPlayback,
Expand Down
16 changes: 16 additions & 0 deletions client/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@ import { defineConfig, searchForWorkspaceRoot } from "vite";
import vue from "@vitejs/plugin-vue";
import vuetify from "vite-plugin-vuetify";
import path from "path";
import child_process from "child_process";

function gitCommit() {
if (process.env.GIT_COMMIT) {
return process.env.GIT_COMMIT.trim();
}
try {
return child_process.execSync("git rev-parse --short HEAD").toString().trim();
} catch (e) {
// eslint-disable-next-line no-console
console.warn("Failed to get git commit hash");
return "unknown";
}
}
// https://vitejs.dev/config/
export default defineConfig({
define: {
__COMMIT_HASH__: JSON.stringify(gitCommit()),
},
base: process.env.OTT_BASE_URL || "/",
plugins: [
vue(),
Expand Down
3 changes: 3 additions & 0 deletions deploy/monolith.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:18-alpine3.16 as build-stage
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT

WORKDIR /usr/app

Expand All @@ -15,6 +17,7 @@ ARG DEPLOY_TARGET
WORKDIR /usr/app/

ENV NODE_ENV production
ENV FFPROBE_PATH /usr/bin/ffprobe

RUN apk update -q && apk --no-cache add curl ffmpeg -q

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ services:
image: dyc3/opentogethertube:latest
container_name: opentogethertube
environment:
- PORT=8080
- REDIS_HOST=redis_db
- REDIS_PORT=6379
- FFPROBE_PATH=/usr/bin/ffprobe
# postgres
- POSTGRES_USER=opentogethertube
- POSTGRES_DB=opentogethertube
Expand Down
7 changes: 2 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:18-alpine3.16 as build-stage
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT

WORKDIR /usr/app

Expand All @@ -13,12 +15,7 @@ FROM node:18-alpine3.16 as production-stage

WORKDIR /usr/app/

# Environnement variable redis/postgres/webport
ENV REDIS_PORT 6379
# Environnement variable nodejs
ENV NODE_ENV production
ENV PORT 8080
# Env variable for external ffprobe
ENV FFPROBE_PATH /usr/bin/ffprobe

RUN apk update -q && apk --no-cache add curl ffmpeg -q
Expand Down
4 changes: 4 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ services:
build:
context: ../
dockerfile: docker/Dockerfile
args:
- GIT_COMMIT=${GIT_COMMIT:-$(git rev-parse HEAD)}
container_name: opentogethertube
environment:
- PORT=8080
- REDIS_HOST=redis_db
- REDIS_PORT=6379
- FFPROBE_PATH=/usr/bin/ffprobe
# postgres
- POSTGRES_USER=opentogethertube
Expand Down

0 comments on commit 0713c75

Please sign in to comment.