docker image fix (#151)
* frontend docker build: pass GIT_COMMIT_HASH and GIT_BRANCH_NAME as env vars to remove dependency on git in webpack.config.js (for glitchtip) fixes #150 * default to "unknown" if git and env vars not available * add comment about error reporting for local use Co-authored-by: sua yoo <sua@suayoo.com>
This commit is contained in:
parent
9bd402fa17
commit
8ede386a8b
2
build-frontend.sh
Executable file
2
build-frontend.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker buildx build --build-arg GIT_COMMIT_HASH="$(git rev-parse --short HEAD)" --build-arg GIT_BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)" --build-arg RWP_BASE_URL="https://replayweb.page/" --platform linux/amd64 --push -t registry.digitalocean.com/btrix/webrecorder/browsertrix-frontend ./frontend/
|
@ -10,6 +10,13 @@ COPY yarn.lock .
|
|||||||
RUN yarn --frozen-lockfile
|
RUN yarn --frozen-lockfile
|
||||||
COPY *.* ./
|
COPY *.* ./
|
||||||
COPY src ./src/
|
COPY src ./src/
|
||||||
|
|
||||||
|
ARG GIT_COMMIT_HASH
|
||||||
|
ENV GIT_COMMIT_HASH=${GIT_COMMIT_HASH}
|
||||||
|
|
||||||
|
ARG GIT_BRANCH_NAME
|
||||||
|
ENV GIT_BRANCH_NAME=${GIT_BRANCH_NAME}
|
||||||
|
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
FROM nginx
|
FROM nginx
|
||||||
|
@ -17,14 +17,21 @@ const dotEnvPath = path.resolve(
|
|||||||
);
|
);
|
||||||
// Get git info to use as Glitchtip release version
|
// Get git info to use as Glitchtip release version
|
||||||
|
|
||||||
const gitBranch = childProcess
|
const execCommand = (cmd, defValue) => {
|
||||||
.execSync("git rev-parse --abbrev-ref HEAD")
|
try {
|
||||||
.toString()
|
return childProcess.execSync(cmd).toString().trim();
|
||||||
.trim();
|
} catch (e) {
|
||||||
const commitHash = childProcess
|
return defValue;
|
||||||
.execSync("git rev-parse --short HEAD")
|
}
|
||||||
.toString()
|
}
|
||||||
.trim();
|
|
||||||
|
// Local dev only
|
||||||
|
// Git branch and commit hash is used to add build info to error reporter when running locally
|
||||||
|
const gitBranch = process.env.GIT_BRANCH_NAME ||
|
||||||
|
execCommand("git rev-parse --abbrev-ref HEAD", "unknown");
|
||||||
|
|
||||||
|
const commitHash = process.env.GIT_COMMIT_HASH ||
|
||||||
|
execCommand("git rev-parse --short HEAD", "unknown");
|
||||||
|
|
||||||
require("dotenv").config({
|
require("dotenv").config({
|
||||||
path: dotEnvPath,
|
path: dotEnvPath,
|
||||||
|
Loading…
Reference in New Issue
Block a user