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 | ||||
| COPY *.* ./ | ||||
| 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 | ||||
| 
 | ||||
| FROM nginx | ||||
|  | ||||
| @ -17,14 +17,21 @@ const dotEnvPath = path.resolve( | ||||
| ); | ||||
| // Get git info to use as Glitchtip release version
 | ||||
| 
 | ||||
| const gitBranch = childProcess | ||||
|   .execSync("git rev-parse --abbrev-ref HEAD") | ||||
|   .toString() | ||||
|   .trim(); | ||||
| const commitHash = childProcess | ||||
|   .execSync("git rev-parse --short HEAD") | ||||
|   .toString() | ||||
|   .trim(); | ||||
| const execCommand = (cmd, defValue) => { | ||||
|   try { | ||||
|     return childProcess.execSync(cmd).toString().trim(); | ||||
|   } catch (e) { | ||||
|     return defValue; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| // 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({ | ||||
|   path: dotEnvPath, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user