Skip to content

Commit acea1d9

Browse files
authored
Merge pull request #2 from antoniomika/am/zsh-and-other-fixes
Added ZSH and some other fixes
2 parents 80cde56 + 2b2f3a6 commit acea1d9

File tree

8 files changed

+146
-334
lines changed

8 files changed

+146
-334
lines changed

.github/workflows/docker.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ name: Docker Image CI
33
on:
44
push:
55
tags:
6-
- v*
6+
- v*
77
branches:
8-
- master
8+
- main
99
pull_request:
1010
branches:
11-
- master
11+
- main
1212

1313
jobs:
1414
build:
15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-20.04
1616
steps:
1717
- uses: actions/checkout@v2
1818
- name: Lint the codebase
19-
uses: golangci/golangci-lint-action@v1
19+
uses: golangci/golangci-lint-action@v2
2020
with:
21-
version: v1.31
21+
version: latest
2222
args: -E goimports -E godot
2323
- name: Set up QEMU
2424
uses: docker/setup-qemu-action@v1
@@ -48,7 +48,7 @@ jobs:
4848
fi
4949
5050
DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
51-
REF="${BRANCH_NAME:-master}"
51+
REF="${BRANCH_NAME:-main}"
5252
OTHER_ARGS=""
5353
OTHER_PUSH_ARGS=""
5454

.github/workflows/release.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ on:
55
- v*
66
jobs:
77
goreleaser:
8-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-20.04
99
steps:
1010
- name: Checkout
1111
uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 0
1214
- name: Set up Go
1315
uses: actions/setup-go@v2
1416
with:

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ENV GOOS=${TARGETOS} GOARCH=${TARGETARCH}
3535

3636
RUN go build -o /go/bin/app -ldflags="-s -w -X github.com/${REPOSITORY}/cmd.Version=${VERSION} -X github.com/${REPOSITORY}/cmd.Commit=${COMMIT} -X github.com/${REPOSITORY}/cmd.Date=${DATE}"
3737

38-
FROM alpine as release
38+
FROM snkshukla/alpine-zsh as release
3939
LABEL maintainer="Antonio Mika <[email protected]>"
4040

4141
WORKDIR /app

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ This configuration will deploy [httpbin](https://httpbin.org) to be accessible f
4343
4. Add a remote that points to pcompose
4444
- `git remote add origin pcompose ssh://example.com:2222/user/httpbin`
4545
5. Push to the pcompose remote
46-
- `git push pcompose master`
46+
- `git push pcompose main`
4747

4848
After step 5, you should see some output that looks like this:
4949

@@ -57,7 +57,7 @@ Total 3 (delta 1), reused 0 (delta 0)
5757
remote: Creating user_httpbin_whoami_1 ... done
5858
remote:
5959
To ssh://example.com:2222/user/httpbin
60-
95fae00..a34685d master -> master
60+
95fae00..a34685d main -> main
6161
```
6262

6363
Once that's done, you should be ready to access your service at `https://http.example.com`

go.mod

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
module github.com/antoniomika/pcompose
22

3+
go 1.15
4+
35
require (
4-
github.com/antoniomika/sish v1.0.2
6+
github.com/antoniomika/sish v1.1.5
57
github.com/creack/pty v1.1.11
68
github.com/fsnotify/fsnotify v1.4.9
7-
github.com/json-iterator/go v1.1.10 // indirect
8-
github.com/mitchellh/mapstructure v1.3.2 // indirect
9-
github.com/phuslu/geoip v1.0.20200531 // indirect
10-
github.com/sirupsen/logrus v1.6.0
11-
github.com/spf13/cobra v1.0.0
12-
github.com/spf13/viper v1.7.0
13-
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9
14-
golang.org/x/sys v0.0.0-20200610111108-226ff32320da // indirect
15-
google.golang.org/protobuf v1.24.0 // indirect
16-
gopkg.in/ini.v1 v1.57.0 // indirect
9+
github.com/sirupsen/logrus v1.7.0
10+
github.com/spf13/cobra v1.1.3
11+
github.com/spf13/viper v1.7.1
12+
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
1713
gopkg.in/natefinch/lumberjack.v2 v2.0.0
1814
)
1915

20-
go 1.15
16+
replace github.com/pires/go-proxyproto => github.com/antoniomika/go-proxyproto v0.1.4-0.20210215223815-7210fcdac442
17+
18+
replace github.com/vulcand/oxy => github.com/antoniomika/oxy v1.1.1-0.20210215225031-0afb828604bb

go.sum

+101-307
Large diffs are not rendered by default.

hook/hook.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,17 @@ func handlePostReceive(hookType, repoDir, oldRev, newRev, refName string) {
8484
os.Exit(1)
8585
}
8686

87-
resetCmd := exec.Command("git", "reset", "origin/master", "--hard")
87+
mainBranchCmd := exec.Command("sh", "-c", "git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'")
88+
mainBranchCmd.Dir = deploymentDir
89+
mainBranchCmd.Env = append(mainBranchCmd.Env, "GIT_DIR=.git")
90+
91+
mainBranch, err := mainBranchCmd.Output()
92+
if err != nil {
93+
log.Println("Error getting main branch:", err)
94+
os.Exit(1)
95+
}
96+
97+
resetCmd := exec.Command("git", "reset", fmt.Sprintf("origin/%s", mainBranch), "--hard")
8898
resetCmd.Dir = deploymentDir
8999
resetCmd.Env = append(resetCmd.Env, "GIT_DIR=.git")
90100
err = resetCmd.Run()
@@ -130,5 +140,9 @@ func handlePostReceive(hookType, repoDir, oldRev, newRev, refName string) {
130140
cmd.Stdout = os.Stdout
131141
cmd.Stderr = os.Stderr
132142

133-
_ = cmd.Run()
143+
err = cmd.Run()
144+
if err != nil {
145+
log.Println("Error running docker-compose up:", err)
146+
os.Exit(1)
147+
}
134148
}

sshserver/sshserver.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,14 @@ func handleRequest(sshConn *pUtils.SSHConnHolder, newRequest *ssh.Request, chann
166166
"-e",
167167
fmt.Sprintf("COMPOSE_PROJECT_NAME=%s", strings.ReplaceAll(containerName, string(os.PathSeparator), "_")),
168168
viper.GetString("pcompose-container-name"),
169-
"/bin/sh",
169+
"/bin/zsh",
170170
}...)
171171
} else {
172-
cmd = exec.Command("docker", "exec", "-it", containerName, "/bin/sh")
172+
realCmd := "/bin/sh"
173+
if containerName == viper.GetString("pcompose-container-name") {
174+
realCmd = "/bin/zsh"
175+
}
176+
cmd = exec.Command("docker", "exec", "-it", containerName, realCmd)
173177
}
174178
}
175179

0 commit comments

Comments
 (0)