Skip to content

Commit

Permalink
完善Dockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Feb 26, 2020
1 parent 8e15159 commit d7ac497
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
6 changes: 4 additions & 2 deletions asset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ ENV VERSION_CHECK "https://api.github.com/repos/Jrohy/trojan/releases/latest"

ENV DOWNLAOD_URL "https://github.com/Jrohy/trojan/releases/download/"

RUN yum install socat bash-completion -y && \
RUN yum install socat bash-completion iptables -y && \
LATEST_VERSION=`curl -H 'Cache-Control: no-cache' -s "$VERSION_CHECK" | grep 'tag_name' | cut -d\" -f4` && \
curl -L "$DOWNLAOD_URL/$LATEST_VERSION/trojan" -o /usr/local/bin/trojan && \
chmod +x /usr/local/bin/trojan && \
echo "source <(trojan completion bash)" >> ~/.bashrc && \
touch /.run.log && \
yum clean all


ENTRYPOINT ["tail", "-f", "/.run.log"]
6 changes: 1 addition & 5 deletions asset/docker_tip.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
docker 运行

#systemctl可用
docker run -d --name test --net=host --privileged trojan-manager init
#容器里面操作容器
docker run -it -d --name test -v /var/run/docker.sock:/var/run/docker.sock -v `which docker`:`which docker` centos tail -f
docker run -it -d --name test --net=host --privileged -v /var/run/docker.sock:/var/run/docker.sock -v `which docker`:`which docker` jrohy/trojan

2 changes: 1 addition & 1 deletion asset/trojan-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ else
echo Skipping installing $NAME server config...
fi

if [[ -d "$SYSTEMDPREFIX" ]]; then
if [[ ! -e "/.dockerenv" && -d "$SYSTEMDPREFIX" ]]; then
echo Installing $NAME systemd service to $SYSTEMDPATH...
if ! [[ -f "$SYSTEMDPATH" ]] || prompt "The systemd service already exists in $SYSTEMDPATH, overwrite?"; then
cat > "$SYSTEMDPATH" << EOF
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/spf13/cobra"
)

const VERSION = "v1.2.0"
const VERSION = "v1.3.0"

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion trojan/trojan.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Start() {

func Stop() {
if util.IsExists("/.dockerenv") {
util.ExecCommand(`ps aux|grep "/usr/bin/trojan/trojan"|grep -v grep|awk '{print $2}'|xargs -r kill -9 2>/dev/null`)
util.ExecCommandWithResult(`ps aux|grep "/usr/bin/trojan/trojan"|grep -v grep|awk '{print $2}'|xargs -r kill -9`)
fmt.Println(util.Green("停止trojan成功!"))
} else {
if err := util.ExecCommand("systemctl stop trojan"); err != nil {
Expand Down

0 comments on commit d7ac497

Please sign in to comment.