Răsfoiți Sursa

Merge pull request #127 from Psiphon-Labs/console-client-docker

Console client docker
Rod Hynes 10 ani în urmă
părinte
comite
0d1443d998
5 a modificat fișierele cu 120 adăugiri și 60 ștergeri
  1. 1 0
      ConsoleClient/.gitignore
  2. 12 23
      ConsoleClient/Dockerfile
  3. 42 4
      ConsoleClient/README.md
  4. 45 31
      ConsoleClient/make.bash
  5. 20 2
      README.md

+ 1 - 0
ConsoleClient/.gitignore

@@ -0,0 +1 @@
+bin

+ 12 - 23
ConsoleClient/Dockerfile

@@ -2,36 +2,25 @@
 #
 # See README.md for usage instructions.
 
-FROM ubuntu:12.04
+FROM ubuntu:15.04
 
-ENV GOVERSION=go1.4.1
+ENV GOVERSION=go1.5
 
 # Install system-level dependencies.
 ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get update && \
-  apt-get -y install build-essential python-software-properties bzip2 unzip curl \
-    git subversion mercurial bzr \
-    upx gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 gcc-multilib
+RUN apt-get update && apt-get -y install build-essential curl git mercurial upx gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 gcc-multilib
 
 # Install Go.
-ENV GOROOT=/go \
-  GOPATH=/
-ENV PATH=$PATH:$GOROOT/bin
-RUN echo "INSTALLING GO" && \
-  curl -L https://github.com/golang/go/archive/$GOVERSION.zip -o /tmp/go.zip && \
-  unzip /tmp/go.zip && \
-  rm /tmp/go.zip && \
-  mv /go-$GOVERSION $GOROOT && \
-  echo $GOVERSION > $GOROOT/VERSION && \
-  cd $GOROOT/src && \
-  ./all.bash
+ENV GOROOT=/usr/local/go GOPATH=/go
+ENV PATH=$PATH:$GOROOT/bin:$GOPATH/bin
+
+RUN curl -L https://storage.googleapis.com/golang/$GOVERSION.linux-amd64.tar.gz -o /tmp/go.tar.gz && \
+  tar -C /usr/local -xzf /tmp/go.tar.gz && \
+  rm /tmp/go.tar.gz && \
+  echo $GOVERSION > $GOROOT/VERSION
 
 ENV CGO_ENABLED=1
-RUN go get github.com/mitchellh/gox && \
-  go get github.com/inconshreveable/gonative && \
-  mkdir -p /usr/local/gonative && \
-  cd /usr/local/gonative && \
-  gonative build
-ENV PATH=/usr/local/gonative/go/bin:$PATH
+
+RUN go get github.com/mitchellh/gox && go get github.com/pwaller/goupx
 
 WORKDIR $GOPATH/src

+ 42 - 4
ConsoleClient/README.md

@@ -1,6 +1,44 @@
-Psiphon Console Client README
-================================================================================
+##Psiphon Console Client README
 
-### Setup
+###Building with Docker
 
-See: https://github.com/Psiphon-Labs/psiphon-tunnel-core#setup
+Note that you may need to use `sudo docker` below, depending on your OS.
+
+#####Create the build image:
+  1. Run the command: `docker build --no-cache=true -t psiclient .` (this may take some time to complete)
+  2. Once completed, verify that you see an image named `psiclient` when running: `docker images`
+
+#####Run the build:
+  *Ensure that the command below is run from within the `ConsoleClient` directory*
+
+  ```bash
+  cd .. && \
+    docker run \
+    --rm \
+    -v $(pwd):/go/src/github.com/Psiphon-Labs/psiphon-tunnel-core \
+    psiclient \
+    /bin/bash -c 'cd /go/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient && ./make.bash' \
+  ; cd -
+  ```
+
+When that command completes, the compiled binaries will be located in the `bin` directory (`./bin`, and everything under it will likely be owned by root, so be sure to `chown` to an appropriate user) under the current directory. The structure will be:
+  ```
+  bin
+  ├── darwin
+  │   └── psiphon-tunnel-core-x86_64
+  ├── linux
+  │   └── psiphon-tunnel-core-i686
+  │   └── psiphon-tunnel-core-x86_64
+  └── windows
+      └── psiphon-tunnel-core-i686.exe
+      └── psiphon-tunnel-core-x86_64.exe
+
+  ```
+
+### Building without Docker
+
+See the [main README build section](../README.md#build)
+
+### Creating a configuration file
+
+See the [main README configuration section](../README.md#configure)

+ 45 - 31
ConsoleClient/make.bash

@@ -1,49 +1,63 @@
 #!/usr/bin/env bash
 
 set -e
-set -exv # verbose output for testing
 
 if [ ! -f make.bash ]; then
-  echo 'make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient'
+  echo "make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient"
   exit 1
 fi
 
-CGO_ENABLED=1
-
-# Make sure we have our dependencies
-echo -e "go-getting dependencies...\n"
-go get -d -v ./...
-
 EXE_BASENAME="psiphon-tunnel-core"
 BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt"
 BUILDDATE=$(date --iso-8601=seconds)
 BUILDREPO=$(git config --get remote.origin.url)
-BUILDREV=$(git rev-parse HEAD)
+BUILDREV=$(git rev-parse --short HEAD)
+
 LDFLAGS="\
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate $BUILDDATE \
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo $BUILDREPO \
 -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev $BUILDREV \
 "
 echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE
-echo -e "LDFLAGS=$LDFLAGS\n"
-
-echo -e "\nBuilding windows-386..."
-CC=/usr/bin/i686-w64-mingw32-gcc \
-  gox -verbose -ldflags "$LDFLAGS" -osarch windows/386 -output windows_386_${EXE_BASENAME}
-# We are finding that UPXing the full Windows Psiphon client produces better results
-# if psiphon-tunnel-core.exe is not already UPX'd.
-#upx --best windows_386_${EXE_BASENAME}.exe
-
-echo -e "\nBuilding windows-amd64..."
-CC=/usr/bin/x86_64-w64-mingw32-gcc \
-  gox -verbose -ldflags "$LDFLAGS" -osarch windows/amd64 -output windows_amd64_${EXE_BASENAME}
-upx --best windows_amd64_${EXE_BASENAME}.exe
-
-echo -e "\nBuilding linux-amd64..."
-gox -verbose -ldflags "$LDFLAGS" -osarch linux/amd64 -output linux_amd64_${EXE_BASENAME}
-upx --best linux_amd64_${EXE_BASENAME}
-
-echo -e "\nBuilding linux-386..."
-CFLAGS=-m32 \
-  gox -verbose -ldflags "$LDFLAGS" -osarch linux/386 -output linux_386_${EXE_BASENAME}
-upx --best linux_386_${EXE_BASENAME}
+
+echo "Variables for ldflags:"
+echo " Build date: ${BUILDDATE}"
+echo " Build repo: ${BUILDREPO}"
+echo " Build revision: ${BUILDREV}"
+echo ""
+
+echo "Getting project dependencies (via go get)"
+GOOS=linux go get -d -v ./...
+GOOS=windows go get -d -v ./...
+GOOS=darwin go get -d -v ./...
+
+if [ ! -d bin ]; then
+  mkdir bin
+fi
+
+echo "Building windows-i686..."
+CC=/usr/bin/i686-w64-mingw32-gcc gox -verbose -ldflags "$LDFLAGS" -osarch windows/386 -output bin/windows/${EXE_BASENAME}-i686
+# We are finding that UPXing the full Windows Psiphon client produces better results if psiphon-tunnel-core.exe is not already UPX'd.
+echo "..No UPX for this build"
+
+echo "Building windows-x86_64..."
+CC=/usr/bin/x86_64-w64-mingw32-gcc gox -verbose -ldflags "$LDFLAGS" -osarch windows/amd64 -output bin/windows/${EXE_BASENAME}-x86_64
+# We are finding that UPXing the full Windows Psiphon client produces better results if psiphon-tunnel-core.exe is not already UPX'd.
+echo "..No UPX for this build"
+
+echo "Building linux-i686..."
+CFLAGS=-m32 gox -verbose -ldflags "$LDFLAGS" -osarch linux/386 -output bin/linux/${EXE_BASENAME}-i686
+echo "..UPX packaging output"
+goupx --best bin/linux/${EXE_BASENAME}-i686
+
+echo "Building linux-x86_64..."
+gox -verbose -ldflags "$LDFLAGS" -osarch linux/amd64 -output bin/linux/${EXE_BASENAME}-x86_64
+echo "..UPX packaging output"
+goupx --best bin/linux/${EXE_BASENAME}-x86_64
+
+echo "Building darwin-x86_64..."
+CGO_ENABLED=0 gox -verbose -ldflags "$LDFLAGS" -osarch darwin/amd64 -output bin/darwin/${EXE_BASENAME}-x86_64
+# Darwin binaries don't seem to be UPXable when built this way
+echo "..No UPX for this build"
+
+echo "Done"

+ 20 - 2
README.md

@@ -18,6 +18,8 @@ This project is currently at the proof-of-concept stage. Current production Psip
 Setup
 --------------------------------------------------------------------------------
 
+#### Build
+
 * Go 1.5 (or higher) is required.
 * This project builds and runs on recent versions of Windows, Linux, and Mac OS X.
 * Note that the `psiphon` package is imported using the absolute path `github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon`; without further local configuration, `go` will use this version of the code and not the local copy in the repository.
@@ -35,7 +37,10 @@ Setup
     "
     ```
 
-* Run `./ConsoleClient --config psiphon.config` where the config file looks like this:
+#### Configure
+
+ * Configuration files are standard text files containing a valid JSON object. Example:
+
 
   <!--BEGIN-SAMPLE-CONFIG-->
   ```
@@ -48,10 +53,23 @@ Setup
   ```
   <!--END-SAMPLE-CONFIG-->
 
-* Config file parameters are [documented here](https://godoc.org/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon#Config).
+*Note: The lines `<!--BEGIN-SAMPLE-CONFIG-->` and `<--END-SAMPLE-CONFIG-->` (visible in the raw Markdown) are used by the [config test](psiphon/config_test.go). Do not remove them.*
+
+* All config file parameters are [documented here](https://godoc.org/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon#Config).
 * Replace each `<placeholder>` with a value from your Psiphon network. The Psiphon server-side stack is open source and can be found in our  [Psiphon 3 repository](https://bitbucket.org/psiphon/psiphon-circumvention-system). If you would like to use the Psiphon Inc. network, contact <developer-support@psiphon.ca>.
+
+
+#### Run
+
+* Run `./ConsoleClient --config psiphon.config` where `psiphon.config` is created as described in the [Configure](#configure) section above
+
+
+Other Platforms
+--------------------------------------------------------------------------------
+
 * The project builds and runs on Android. See the [AndroidLibrary README](AndroidLibrary/README.md) for more information about building the Go component, and the [AndroidApp README](AndroidApp/README.md) for a sample Android app that uses it.
 
+
 Licensing
 --------------------------------------------------------------------------------