Skip to content

Commit

Permalink
Add Dockerfile for local development
Browse files Browse the repository at this point in the history
Closes #59
  • Loading branch information
edwardtheharris committed Oct 2, 2024
1 parent ef71b1b commit dd2715c
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 16 deletions.
61 changes: 45 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,69 @@
###### Development
# Readme

## Development

Prerequisites:

- `curl` or `wget`
- `jq`
- an account for Symbiont's portal

```shell
source ./test.sh
```
### Usage

For usage against the staging portal, append a `--registry=<registry>` to commands that perform remote operations. Note that
you will also need to use a token created by said registry in order for authentication to work. If need be, use `symenv reset`
to clear your authentication token.
```shell
symenv install --registry=portal-staging.waf-symbiont.io
```
1. Prepare the environment.

```shell
source ./test.sh
```

You should see output similar to this.

```shell
=> Downloading symenv as script to '/root/.symbiont'
[1]- Done symenv_download -s "$SYMENV_SOURCE_LOCAL" -o "$INSTALL_DIR/symenv.sh" || { symenv_echo "Failed to download '$SYMENV_SOURCE_LOCAL'" 1>&2; return 1; }
[2]+ Done symenv_download -s "$SYMENV_BASH_COMPLETION_SOURCE" -o "$INSTALL_DIR/bash_completion" || { symenv_echo "Failed to download '$SYMENV_BASH_COMPLETION_SOURCE'" 1>&2; return 2; }

=> Append to profile file then close and reopen your terminal to start using symenv or run the following to use it now:

export SYMENV_DIR="$HOME/.symbiont"
[ -s "$SYMENV_DIR/symenv.sh" ] && \. "$SYMENV_DIR/symenv.sh" # This loads symenv
[ -s "$SYMENV_DIR/versions/current" ] && export PATH="$SYMENV_DIR/versions/current/bin":$PATH # This loads symenv managed SDK
[ -s "$SYMENV_DIR/bash_completion" ] && \. "$SYMENV_DIR/bash_completion" # This loads symenv bash_completion
```

###### Installation
2. Choose a registry by appending the `--registry=<registry>` flag to commands
that perform remote operations.

> Note that you will also need to use a token created by said registry
> in order for authentication to work.
>
> If need be, use `symenv reset` to clear your authentication token.
3. Install the environment.

```shell
symenv install --registry=portal-staging.waf-symbiont.io
```

## Installation

Prerequisites:

- `curl` or `wget`
- `jq`
- an account for Symbiont's portal

Remotely

```shell
curl --proto '=https' --tlsv1.2 -sSf https://<host>/<path>/install.sh | bash
```

eg.
```shell
# Example

curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/symbiont-io/symenv/main/install.sh | bash
```

###### Commands
### Commands

```help
Usage:
Expand All @@ -52,4 +82,3 @@ Usage:
--all Include the non-release versions
symenv reset Resets your environment to a fresh install of symenv
```

36 changes: 36 additions & 0 deletions docker/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# shellcheck disable=SC1091

CLICOLOR=1
# shellcheck disable=SC2016
LESS='-R --use-color -Dd+r$Du+b$'
LSCOLORS="Ea"
PS1="[\[$(tput sgr0)\]\[\033[38;5;1m\]\u\[$(tput sgr0)\]\[\033[3f8;5;15m\]@\[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;6m\]\H\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;46m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]]{\[$(tput sgr0)\]\[\033[38;5;57m\]\$?\[$(tput sgr0)\]\[\033[38;5;15m\]} \[$(tput sgr0)\]"

# shellcheck disable=SC1091
if [ -f /usr/share/bash-completion/bash_completion ]; then
source /usr/share/bash-completion/bash_completion
fi

SYMENV_DIR="$HOME/.symbiont"

# This loads symenv
if [ -s "$SYMENV_DIR/symenv.sh" ]; then
/bin/bash "$SYMENV_DIR/symenv.sh"
fi
# This loads symenv managed SDK
if [ -s "$SYMENV_DIR/versions/current" ]; then
PATH="$SYMENV_DIR/versions/current/bin:$PATH"
export PATH
fi

# This loads symenv bash_completion
if [ -s "$SYMENV_DIR/bash_completion" ]; then
source "$SYMENV_DIR/bash_completion"
fi

export CLICOLOR
export LESS
export LSCOLORS
export PS1
export PATH
10 changes: 10 additions & 0 deletions docker/.zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/zsh

export SYMENV_DIR="$HOME/.symbiont"

# This loads symenv
[ -s "$SYMENV_DIR/symenv.sh" ] && \. "$SYMENV_DIR/symenv.sh"
# This loads symenv managed SDK
[ -s "$SYMENV_DIR/versions/current" ] && export PATH="$SYMENV_DIR/versions/current/bin":$PATH
# This loads symenv bash_completion
[ -s "$SYMENV_DIR/bash_completion" ] && \. "$SYMENV_DIR/bash_completion"
19 changes: 19 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM archlinux/archlinux:base-devel
RUN pacman -Syyu --noconfirm \
bash_completion \
curl \
git \
jq \
unzip \
vim \
wget \
zip \
zsh \
&& ln -sfv /usr/bin/vim /usr/bin/vi \
&& mkdir -pv /usr/src/symenv/docker
WORKDIR /usr/src/symenv
COPY docker/test.sh /usr/src/symenv/docker/test.sh
RUN /bin/bash /usr/src/symenv/docker/test.sh
COPY docker/.zshrc /root/.zshrc
COPY docker/.bashrc /root/.bashrc
CMD ["/bin/bash"]
54 changes: 54 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Symenv Docker Build

There are two steps here.

1. Build the Docker image to run locally.

```shell
docker build -t ghcr.io/platonic-io/symenv:${USER}-$(date +%Y-%m-%d) -f docker/Dockerfile --progress plain .
```

2. Add required volumes.
1. The Symbiont Node requires this repository and the
symbiont-node repository to run. Provide these with bind mounts or
volumes.
2. To use a bind mount
1. Clone the symbiont-node repository to the parent
directory of this repository's root
2. Run the container using the bind mount step below
3. To use volumes
1. Create the volumes

```shell
docker volume create symenv
docker volume create symbiont-node
```

2. Run the container using the volumes step below
3. Copy the repositories into each volume once the container is running

```shell
SYMBIONT_NODE_REPO_PATH="/home/${USER}/Documents/src/github.com/platonic-io/symbiont-node"
SYMENV_REPO_PATH="/home/${USER}/Documents/src/github.com/platonic-io/symenv"
docker copy $SYMBIONT_NODE_REPO_PATH symbiont-node:/usr/src/symbiont-node
docker copy $SYMENV symenv:/usr/src/symenv
```

3. Run a container named `symenv` with the image we just built.
1. Using a bind mount.

```shell
docker run --name symenv \
-v /home/${USER}/Documents/src/github.com/platonic-io/symbiont-node:/usr/src/symbiont-node \
-v $(pwd):/usr/src/symenv -it ghcr.io/platonic-io/symenv:${USER}-${date +%Y-%m-%d} bash
```

2. Using volumes

```shell
docker run --name symenv \
-v symenv:/usr/src/symenv \
-v symbiont-node:/usr/src/symbiont-node \
-it ghcr.io/platonic-io/symenv:${USER}-${date +%Y-%m-$d} bash
```
9 changes: 9 additions & 0 deletions docker/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env sh

SYM_DIR="$(pwd)"

export SYM_DIR

if [ -s "$SYM_DIR/symenv.sh" ]; then
/bin/sh "$SYM_DIR/symenv.sh"
fi

0 comments on commit dd2715c

Please sign in to comment.