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 3, 2024
1 parent ef71b1b commit 6679a56
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
symenv_debug.log
reflog
21 changes: 13 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
# symenv

## [1.2.16] - 2022-05-24
## [1.2.17](https://github.com/platonic-io/symenv/releases/tag/v1.2.17)

### Added
### Fixed 1.2.17 - 2022-07-20

- Fixed artifact ordering by expecting 0s in the artifact counter (#53)

## [1.2.16](https://github.com/platonic-io/symenv/releases/tag/v1.2.16)

### Added - 2022-05-24

- Login function which is independent from any other commands.

## [1.2.13] - 2020-03-30
## [1.2.13](https://github.com/platonic-io/symenv/releases/tag/v1.2.13)

### Removed
### Removed 1.2.13 - 2022-03-29

- Remove ability to install VSCode extension

### Fixed
### Fixed 1.2.13

- Symenv timeout issue with auth requests. It will timeout in 30 seconds now

## [1.2.12](https://github.com/platonic-io/symenv/releases/tag/v1.2.12)

## [1.2.12] - 2020-03-28

### Fixed
### Fixed 1.2.12 - 2020-03-28

- Add error catching for package download failures
- Extract package tar directly to correct directory
65 changes: 49 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,73 @@
###### 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
```

2. Choose a registry by appending the `--registry=portal.platonic.io` flag to commands
that perform remote operations.

###### Installation
> 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.platonic.io v4.1.0
```

### Docker Usage

You can find information on how to build and run a container with symenv [here](docker/README.md).

## 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 +86,3 @@ Usage:
--all Include the non-release versions
symenv reset Resets your environment to a fresh install of symenv
```

2 changes: 1 addition & 1 deletion auth_example_flow.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash

CODE_REQUEST_RESPONSE=$(curl --silent --proto '=https' --tlsv1.2 --request POST \
--url "https://internal-portal.us.auth0.com/oauth/device/code" \
Expand Down
25 changes: 25 additions & 0 deletions docker/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
# shellcheck disable=SC1091

CLICOLOR=1
# shellcheck disable=SC2016
LESS='-R --use-color -Dd+r$Du+b$'
LSCOLORS="Ea"
PS1='[\[\e[31m\]\u\[\e[0m\]@\[\e[32m\]\H\[\e[0m\]:\[\e[33m\]\w\[\e[0m\]]{\[\e[34m\]$?\[\e[0m\]}\$ '
SYMENV_DIR="$HOME/.symbiont"

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

PATH="$SYMENV_DIR/versions/current/bin:$PATH"

. "$HOME/.symbiont/symenv.sh"
. "$HOME/.symbiont/bash_completion"

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

export SYMENV_DIR="$HOME/.symbiont"

# This loads symenv
if [ -f "$SYMENV_DIR/symenv.sh" ]; then
source "$SYMENV_DIR/symenv.sh"
fi

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

# This loads symenv bash_completion
if [ -f "$SYMENV_DIR/bash_completion" ]; then
source "$SYMENV_DIR/bash_completion"
fi
24 changes: 24 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1
FROM archlinux/archlinux:base-devel
ARG DATE="2024-10-02"
LABEL org.opencontainers.image.source="https://github.com/platonic-io/symenv"
LABEL org.opencontainers.image.authors="[email protected]"
LABEL org.opencontainers.image.date="${DATE}"
RUN pacman -Syyu --noconfirm \
bash-completion \
curl \
git \
jq \
unzip \
vim \
wget \
zip \
zsh \
&& ln -sfv /usr/bin/vim /usr/bin/vi \
&& useradd -s /bin/bash -m -g users -d /home/symenv symenv
COPY docker/.zshrc /home/symenv/.zshrc
COPY docker/.bashrc /home/symenv/.bashrc
USER symenv
RUN curl -L https://raw.githubusercontent.com/symbiont-io/symenv/main/install.sh | bash
WORKDIR /home/symenv/
CMD ["/bin/bash"]
45 changes: 45 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Symenv Docker Build

There are two steps here.

1. Build the Docker image to run locally.

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

2. Run a container named `symenv` with the image we just built.

```shell
docker run --name symenv -v $(pwd):/usr/src/symenv -it "ghcr.io/platonic-io/symenv:${USER}" bash
```

3. From the running container you can list the remote versions available to install.

```shell
symenv ls-remote --registry=portal.platonic.io --force-auth
```

1. Follow the instructions to complete your login.
2. Then attend to the list of available versions produced.

```shell
✅ Authentication successful
v2.0.0
v2.0.1
v2.0.2
v2.0.3
v3.0.0
v4.0.0
v4.1.0
```

4. Now install one or more of them.

```shell
symenv install --registry=portal.platonic.io v4.1.0
```

You are now ready to deploy resources to the cloud of your choice.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash

{ # this ensures the entire script is downloaded #

Expand Down
10 changes: 5 additions & 5 deletions symenv.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/bash
# shellcheck disable=SC2039
# ^-- Ignore warning about `local`s

Expand Down Expand Up @@ -472,7 +472,7 @@
;;
--force) FORCE_REINSTALL=1 ;;
--debug) ;;
--force-auth) ;;
--force-auth) ;;
*)
if [ -n "${1-}" ]; then
PROVIDED_VERSION="$1"
Expand Down Expand Up @@ -540,7 +540,7 @@
symenv_err "SDK Failed to Download"
return 44
fi

tar xzf "${TARGET_FILE}" --directory "${TARGET_PATH}" --strip-components=2
rm "${TARGET_FILE}"

Expand All @@ -566,7 +566,7 @@

#if there's no match, sed will just output the key itself
# otherwise set the key equal to the left size of the equal and set the value to the right side
if [[ "$(echo $KEY | sed 's/^\(.*\)=\(.*\)$/\2/g' )" != $KEY && $VALUE == "" ]]; then
if [[ "$(echo $KEY | sed 's/^\(.*\)=\(.*\)$/\2/g' )" != $KEY && $VALUE == "" ]]; then
symenv_debug "Equals passed to ${KEY} and no value ${VALUE}"
VALUE="$(echo $KEY | sed 's/\(.*\)=\(.*\)/\2/g' )"
KEY="$(echo $KEY | sed 's/\(.*\)=\(.*\)/\1/g' )"
Expand Down Expand Up @@ -674,7 +674,7 @@
else
# Otherwise, no file, means we go from scratch
symenv_do_auth "$REGISTRY"
if [ "" = "${SYMENV_ACCESS_TOKEN}" ] | [ null = "${SYMENV_ACCESS_TOKEN}" ]; then
if [ "" = "${SYMENV_ACCESS_TOKEN}" ] | [ null = "${SYMENV_ACCESS_TOKEN}" ]; then
return 1
fi
touch "${HOME}/.symenvrc"
Expand Down
11 changes: 8 additions & 3 deletions test.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env sh
#!/bin/sh

export SYM_DIR=`pwd`
[ -s "$SYM_DIR/symenv.sh" ] && \. "$SYM_DIR/symenv.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 6679a56

Please sign in to comment.