File tree 3 files changed +77
-0
lines changed
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ Dockerfile.windows
2
+ package-lock.json
Original file line number Diff line number Diff line change
1
+ # !/usr/bin/env pwsh
2
+ # PowerShell 7.5
3
+ $ErrorActionPreference = ' Stop'
4
+ Set-StrictMode - Version Latest
5
+
6
+ # Get the script's directory and navigate to the parent directory.
7
+ $scriptDir = Split-Path $MyInvocation.MyCommand.Definition - Parent
8
+ Push-Location (Join-Path $scriptDir ' ..' )
9
+ try {
10
+ & npm install
11
+ & npm run build
12
+ Remove-Item ./ dist/ openai- codex-* .tgz - Recurse - Force - ErrorAction Ignore
13
+ & npm pack -- pack- destination ./ dist
14
+ Move-Item ./ dist/ openai- codex-* .tgz ./ dist/ codex.tgz - Force
15
+
16
+ # Dockerfile Patch to Resolve Permission Issues on Windows
17
+ Copy-Item - Path ./ Dockerfile - Destination ./ Dockerfile.windows - Force
18
+ echo ' RUN git config --global --add safe.directory /app' >> ./ Dockerfile.windows
19
+
20
+ & docker build - t codex -f ' ./Dockerfile.windows' .
21
+ }
22
+ finally {
23
+ Pop-Location
24
+ }
Original file line number Diff line number Diff line change
1
+ # !/usr/bin/env pwsh
2
+ # PowerShell 7.5
3
+ <#
4
+ Usage:
5
+ .\run_in_container.ps1 [-WorkDir <directory>] -- <PROMPT>
6
+ Example:
7
+ .\run_in_container.ps1 -WorkDir G:\Projects\demo1 -- "explain this codebase to me"
8
+ .\run_in_container.ps1
9
+ #>
10
+
11
+ param (
12
+ [string ]$WorkDir = (Get-Location ).ProviderPath,
13
+ [Parameter (ValueFromRemainingArguments )] [string []]$Args
14
+ )
15
+
16
+ $WorkDir = (Get-Item $WorkDir ).FullName
17
+ $containerName = ' codex_' + ($WorkDir -replace ' [\\/]' , ' _' -replace ' [^0-9A-Za-z_-]' , ' ' )
18
+
19
+ # Check whether OPENAI_API_KEY has been set in environment variables.
20
+ if (-not $env: OPENAI_API_KEY ) {
21
+ Write-Error ' An OPENAI_API_KEY environment variable must be provided.'
22
+ exit 1
23
+ }
24
+
25
+ function Cleanup {
26
+ docker rm -f $containerName 2> $null
27
+ }
28
+
29
+ function Quote-BashArg {
30
+ param ([string ]$Value )
31
+ return " '$ ( $Value -replace " '" , " ''\'''" ) '"
32
+ }
33
+
34
+ try {
35
+ Cleanup # Remove old container
36
+
37
+ docker run -- name $containerName - d `
38
+ - e OPENAI_API_KEY `
39
+ -- cap- add= NET_ADMIN -- cap- add= NET_RAW `
40
+ - v " ${WorkDir} :/app" `
41
+ codex sleep infinity | Out-Null
42
+
43
+ # docker exec $containerName bash -c 'sudo /usr/local/bin/init_firewall.sh'
44
+
45
+ $quoted = ($Args | ForEach-Object { Quote- BashArg $_ }) -join ' '
46
+
47
+ docker exec - it $containerName bash - c " cd '/app' && codex --full-auto $quoted "
48
+ }
49
+ finally {
50
+ Register-EngineEvent PowerShell.Exiting - Action { Cleanup } | Out-Null
51
+ }
You can’t perform that action at this time.
0 commit comments