Skip to content

Commit

Permalink
add installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
goulinkh committed Aug 12, 2024
1 parent 8b458d6 commit 4733269
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 21 deletions.
61 changes: 40 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,52 @@ $ dotrun --image {image-name} # Use a specific image for dotrun. Useful for runn

## Installation

### Docker
### Requirements

First, install [Docker](https://docs.docker.com/get-docker/). On Linux, you can install [Docker snap](https://snapcraft.io/docker) instead.
- Docker ([Get Docker](https://docs.docker.com/get-docker/)): on Linux, you can install the [Docker snap](https://snapcraft.io/docker) instead.
- Python 3.10 or later
- On MacOS: [Homebrew](https://docs.brew.sh/Installation) is required
- `curl` command-line tool (usually pre-installed on macOS and most Linux distributions)

Linux users may also need to follow the [post install instructions](https://docs.docker.com/engine/install/linux-postinstall/) to be able to run Docker as a non-root user.
### Linux and MacOS

### Linux
#### Quick installation

To install dotrun run:
To install dotrun simply run:

```bash
curl -sSL https://raw.githubusercontent.com/canonical/dotrun/main/scripts/install.sh | bash
```
sudo apt install python3-pip
sudo pip3 install dotrun

### Verifying the Installation

After installation, you can verify that `dotrun` is installed correctly by running:

```bash
dotrun version
```

### Mac
### Manual Installation

To install dotrun on a mac you will need [Homebrew](https://brew.sh/) (follow
the install
instructions on that page).
If you prefer to install manually or encounter any issues with the installation script, you can install `dotrun` using the following steps:

Then run:
1. Install `pipx` if you haven't already:

```
brew install python3
sudo pip3 install dotrun
* On macOS: `brew install pipx`
* On Linux: Follow the installation instructions for your distribution from the [pipx documentation](https://pypa.github.io/pipx/installation/)
2. Ensure `pipx` is in your PATH:

```bash
pipx ensurepath
```

### Requirements
1. Install `dotrun` using `pipx`:

- Linux / macOS
- Docker ([Get Docker](https://docs.docker.com/get-docker/))
- Python > 3.6 and PIP
```bash
pipx install dotrun
```

If you experience problems, please open a GitHub issue.

### macOS performance

Expand Down Expand Up @@ -116,28 +129,34 @@ docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --
You can install the package locally using either pip or poetry.

### Using pip

```bash
pip3 install . requests==2.31.0
```

### Using Poetry

```bash
pip install poetry
poetry install --no-interaction
```

To run dotrun off alternative base images such as local images, you can use the `--image` flag.

```bash
dotrun --image "localimage" exec echo hello
```

To run dotrun off alternative releases, besides the `:latest` release, you can use the `--release` flag.

```bash
dotrun --release "latest" serve
```

Note that before changing the base image you should run
Note that before changing the base image you should run

```bash
dotrun clean
```
to get rid of the old virtualenv.

to get rid of the old virtualenv.
83 changes: 83 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

set -e

install_pipx_macos() {
if command -v brew >/dev/null 2>&1; then
echo "Installing pipx using Homebrew..."
brew install pipx
pipx ensurepath
else
echo "Error: Homebrew is not installed on your system."
echo "Please install Homebrew first: https://brew.sh/"
echo "Then run this script again."
exit 1
fi
}
notice_shown=false

sudo_notice() {
if $notice_shown; then
return
fi
echo "-------------------------------------"
echo "This step requires sudo privileges to install system packages."
echo "You may be prompted to enter your password."
echo "-------------------------------------"
notice_shown=true
}
try_sudo() {
# if sudo not installed
if ! command -v sudo >/dev/null 2>&1; then
"$@"
elif [ -z "${SUDO_USER-}" ]; then
sudo "$@"
else
sudo_notice
"$@"
fi
}

install_pipx_linux() {
if command -v apt-get >/dev/null 2>&1; then
echo "Installing pipx using apt..."
sudo_notice
try_sudo apt update
try_sudo apt install -y pipx
pipx ensurepath
elif command -v dnf >/dev/null 2>&1; then
echo "Installing pipx using dnf..."
sudo_notice
try_sudo dnf install -y pipx
pipx ensurepath
elif command -v pacman >/dev/null 2>&1; then
echo "Installing pipx using pacman..."
sudo_notice
try_sudo pacman -Sy --noconfirm python-pipx
pipx ensurepath
else
echo "Error: Your linux distribution is not supported by this script."
echo "Please follow the manual installation instructions: https://github.com/canonical/dotrun?tab=readme-ov-file#installation"
exit 1
fi
}

# Detect the operating system
# macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
install_pipx_macos
# Linux
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
install_pipx_linux
else
echo "Unsupported operating system: $OSTYPE"
echo "Please follow the manual installation instructions: https://github.com/canonical/dotrun?tab=readme-ov-file#installation"
exit 1
fi

# Install dotrun using pipx
echo "Installing dotrun..."
pipx install dotrun

echo "Installation complete!"
echo "You will need to open a new terminal or re-login before using the 'dotrun' command."

0 comments on commit 4733269

Please sign in to comment.