Skip to content

Commit

Permalink
Replace unzip with bsdtar
Browse files Browse the repository at this point in the history
There are situations where a Zip archive from Sourcegraph causes the
directory to be improperly recreated within the container. Using
libarchive-tools fixes this.
  • Loading branch information
lowjoel committed Aug 22, 2023
1 parent b9e783a commit ed8be10
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docker/batch-change-volume-workspace/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

FROM alpine:3.15.0@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300

RUN apk add --update git unzip
RUN apk add --update git libarchive-tools
2 changes: 1 addition & 1 deletion internal/batches/workspace/volume_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (wc *dockerVolumeWorkspaceCreator) unzipRepoIntoVolume(ctx context.Context,
opts,
DockerVolumeWorkspaceImage,
"sh", "-c",
fmt.Sprintf("unzip /tmp/zip; rm /work/%s", dummy),
fmt.Sprintf("bsdtar -xf /tmp/zip && rm /work/%s", dummy),
)

if out, err := exec.CommandContext(ctx, "docker", opts...).CombinedOutput(); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions internal/batches/workspace/volume_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
"--user", "0:0",
"--mount", "type=volume,source="+volumeID+",target=/work",
DockerVolumeWorkspaceImage,
"sh", "-c", "unzip /tmp/zip; rm /work/*",
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
),
expect.NewGlob(
expect.Success,
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
"--user", "0:0",
"--mount", "type=volume,source="+volumeID+",target=/work",
DockerVolumeWorkspaceImage,
"sh", "-c", "unzip /tmp/zip; rm /work/*",
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
),
expect.NewGlob(
expect.Success,
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
"--user", "1:2",
"--mount", "type=volume,source="+volumeID+",target=/work",
DockerVolumeWorkspaceImage,
"sh", "-c", "unzip /tmp/zip; rm /work/*",
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
),
expect.NewGlob(
expect.Success,
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
"--user", "0:0",
"--mount", "type=volume,source="+volumeID+",target=/work",
DockerVolumeWorkspaceImage,
"sh", "-c", "unzip /tmp/zip; rm /work/*",
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
),
expect.NewGlob(
expect.Behaviour{ExitCode: 1},
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
"--user", "0:0",
"--mount", "type=volume,source="+volumeID+",target=/work",
DockerVolumeWorkspaceImage,
"sh", "-c", "unzip /tmp/zip; rm /work/*",
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
),
},
steps: []batcheslib.Step{
Expand Down Expand Up @@ -318,7 +318,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
"--user", "0:0",
"--mount", "type=volume,source="+volumeID+",target=/work",
DockerVolumeWorkspaceImage,
"sh", "-c", "unzip /tmp/zip; rm /work/*",
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
),
expect.NewGlob(
expect.Success,
Expand Down

0 comments on commit ed8be10

Please sign in to comment.