Skip to content

Commit

Permalink
Merge branch 'master' into john/#244-dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
PiggySpeed committed Jun 29, 2018
2 parents 1783b07 + 69c0e0e commit 7151aed
Show file tree
Hide file tree
Showing 44 changed files with 1,127 additions and 303 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve!

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- Client OS [where you are using the Inertia CLI from]
- VPS OS [the platform you are deploying to]
- Project Details [some information about the project you are deploying]
- Version [e.g. v0.4.0]

**Additional context**
Add any other context about the problem here.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-idea.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature idea
about: Suggest an idea for Inertia!

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ users.db
# Vendored dependencies
vendor

# Test output
# Tests
.inertia
inertia*.toml
bumper

# Development
.vscode
Expand Down
2 changes: 1 addition & 1 deletion .scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ make daemon RELEASE=$RELEASE

# Build Inertia Go binaries for specified platforms
gox -output="inertia.$(git describe --tags).{{.OS}}.{{.Arch}}" \
-ldflags "-X main.Version=$RELEASE" \
-ldflags "-w -s -X main.Version=$RELEASE" \
-osarch="$PLATFORMS" \
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ jobs:
- <<: *bootstraptest
install: make testenv VPS_OS=centos VPS_VERSION=7 SSH_PORT=69
- <<: *bootstraptest
install: make testenv VPS_OS=amazon VPS_VERSION=latest SSH_PORT=69
install: make testenv VPS_OS=amazon VPS_VERSION=1 SSH_PORT=69
# - <<: *bootstraptest
# install: make testenv VPS_OS=amazon VPS_VERSION=2 SSH_PORT=69

# Run linter and static analysis
- install: bash test/lint_deps.sh
Expand Down
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN if [ ! -d "vendor" ]; then \
fi
# Build daemon binary.
RUN go build -o /bin/inertiad \
-ldflags "-X main.Version=$INERTIA_VERSION" \
-ldflags "-w -s -X main.Version=$INERTIA_VERSION" \
./daemon/inertiad

### Part 3 - Copy builds into combined image
Expand All @@ -39,5 +39,15 @@ COPY --from=web-build-env \
/go/src/github.com/ubclaunchpad/inertia/daemon/web/public/ \
/daemon/inertia-web

# Directories
ENV INERTIA_PROJECT_DIR=/app/host/inertia/project/ \
INERTIA_SSL_DIR=/app/host/inertia/config/ssl/ \
INERTIA_DATA_DIR=/app/host/inertia/data/ \
INERTIA_GH_KEY_PATH=/app/host/.ssh/id_rsa_inertia_deploy

# Build tool versions
ENV INERTIA_DOCKERCOMPOSE=docker/compose:1.21.0 \
INERTIA_HEROKUISH=gliderlabs/herokuish:v0.4.0

# Serve the daemon by default.
ENTRYPOINT ["inertiad", "run"]
54 changes: 53 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@
[[constraint]]
name = "github.com/gorilla/websocket"
version = "1.2.0"

[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "1.14.10"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ dev-deps:

# Install Inertia with release version
.PHONY: cli
inertia:
cli:
go install -ldflags "-X main.Version=$(RELEASE)"

# Install Inertia with git tag as release version
.PHONY: cli-tagged
inertia-tagged:
cli-tagged:
go install -ldflags "-X main.Version=$(TAG)"

# Remove Inertia binaries
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Inertia is a simple cross-platform command line application that enables quick a
----|-----------------
🚀 | Simple setup from your computer without ever having to manually SSH into your remote
🍰 | Use any Linux-based remote virtual private server platform you want
📦 | Easily provision new VPS instances on supported platforms such as Amazon EC2
⚒ | Deploy a wide range of supported project types (including Dockerfile, docker-compose, and Heroku projects)
🚄 | Have your project automatically updated, rebuilt, and deployed as soon as you `git push`
🛂 | Start up, shut down, and monitor your deployment with ease
Expand Down Expand Up @@ -94,21 +95,30 @@ Initializing a project for use with Inertia only takes a few simple steps:

```bash
$> inertia init
$> inertia remote add $VPS_NAME
```

After adding a remote, you can bring the Inertia daemon online on your VPS:
#### Using an Existing Remote

To use an existing host, you must first add it to your Inertia configuration and initialize it - this will install Inertia on your remote.

```bash
$> inertia remote add $VPS_NAME
$> inertia $VPS_NAME init
$> inertia $VPS_NAME status
# Confirms that the daemon is online and accepting requests
```

This daemon will be used to manage your deployment.

See our [wiki](https://github.com/ubclaunchpad/inertia/wiki/VPS-Compatibility) for more details on VPS platform compatibility.

#### Provisioning a New Remote

Inertia offers some tools to easily provision a new VPS instance and set it up for Inertia. For example, to create an EC2 instance and initialize it, just run:

```bash
$> inertia provision ec2 $VPS_NAME
$> inertia $VPS_NAME status
```

### Deployment Management

To manually deploy your project, you must first grant Inertia permission to clone your repository. This can be done by adding the GitHub Deploy Key that is displayed in the output of `inertia $VPS_NAME init` to your repository settings:
Expand Down
6 changes: 3 additions & 3 deletions client/internal/compiled.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion client/scripts/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@ set -e
DOCKER_SOURCE=get.docker.com
DOCKER_DEST='/tmp/get-docker.sh'

startDockerd() {
# Start dockerd if it is not online
if ! sudo docker stats --no-stream ; then
sudo service docker start
# Poll until dockerd is running
while ! sudo docker stats --no-stream ; do
echo "Waiting for dockerd to launch..."
sleep 1
done
fi
}

# Skip installation if Docker is already installed.
if hash docker 2>/dev/null; then
startDockerd
exit 0
fi;

Expand Down Expand Up @@ -40,4 +53,4 @@ else
fi
fi

sudo service docker start
startDockerd
11 changes: 6 additions & 5 deletions client/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"

"github.com/ubclaunchpad/inertia/cfg"
"golang.org/x/crypto/ssh"
Expand Down Expand Up @@ -124,22 +124,23 @@ func (runner *SSHRunner) CopyFile(file io.Reader, remotePath string, permissions
}
reader := bytes.NewReader(contents)

// Send file contents
filename := path.Base(remotePath)
directory := path.Dir(remotePath)
// Set up
filename := filepath.Base(remotePath)
directory := filepath.Dir(remotePath)
session, err := getSSHSession(runner.pem, runner.ip, runner.sshPort, runner.user)
if err != nil {
return err
}

// Send file contents
go func() {
w, _ := session.StdinPipe()
defer w.Close()
fmt.Fprintln(w, "C"+permissions, len(contents), filename)
io.Copy(w, reader)
fmt.Fprintln(w, "\x00")
}()
session.Run("/usr/bin/scp -t " + directory)
session.Run("mkdir -p " + directory + "; /usr/bin/scp -t " + directory)
return nil
}

Expand Down
27 changes: 27 additions & 0 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@ import (
"io"
"os"
"path/filepath"
"strconv"
"time"
)

// GetFullPath returns the absolute path of the config file.
func GetFullPath(relPath string) (string, error) {
path, err := os.Getwd()
if err != nil {
return "", err
}
return filepath.Join(path, relPath), nil
}

// GenerateRandomString creates a rand.Reader-generated
// string for use with simple secrets and identifiers
func GenerateRandomString() (string, error) {
Expand Down Expand Up @@ -61,3 +72,19 @@ func RemoveContents(directory string) error {
}
return nil
}

// ParseDate parses a date in format "2006-01-02T15:04:05.000Z"
func ParseDate(dateString string) *time.Time {
layout := "2006-01-02T15:04:05.000Z"
t, _ := time.Parse(layout, dateString)
return &t
}

// ParseInt64 parses a string into an int64 value
func ParseInt64(value string) (int64, error) {
i, err := strconv.ParseInt(value, 10, 64)
if err != nil {
return 0, err
}
return i, nil
}
13 changes: 13 additions & 0 deletions common/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,16 @@ func TestExtract(t *testing.T) {
repoNameWithMixed := ExtractRepository("git@github.com:ubclaunchpad/inertia-deploy.test.git")
assert.Equal(t, "ubclaunchpad/inertia-deploy.test", repoNameWithMixed)
}

func TestParseDate(t *testing.T) {
assert.NotNil(t, ParseDate("2006-01-02T15:04:05.000Z"))
}

func TestParseInt64(t *testing.T) {
parsed, err := ParseInt64("10")
assert.Nil(t, err)
assert.Equal(t, int64(10), parsed)

_, err = ParseInt64("")
assert.NotNil(t, err)
}
Loading

0 comments on commit 7151aed

Please sign in to comment.