Skip to content

Instantly share code, notes, and snippets.

@ssplatt
Last active November 12, 2021 17:07
Show Gist options
  • Save ssplatt/74d13501043b57407747530961b083d9 to your computer and use it in GitHub Desktop.
Save ssplatt/74d13501043b57407747530961b083d9 to your computer and use it in GitHub Desktop.
Superalgos Docker Development Environment

build

docker-compose build

or

docker build -t superalgos-dev .

then run

docker-compose up -d

or

docker run -it --rm -v $(pwd)/src:/app -p 34248:34248 -p 18041:18041 superalgos-dev /bin/bash

configure your git environment

Set the GIT_USERNAME and GIT_PERSONAL_ACCESS_TOKEN variables to be able to clone your personal fork and push code to GitHub. You can export them from your .bashrc or .zshrc, set them in a local .env file, or set them right in the docker-compose.yml.

version: "3"
services:
superalgos-dev:
build:
context: .
image: superalgos-dev
ports:
- '34248:34248'
- '18041:18041'
volumes:
- ./src:/app
environment:
GIT_USERNAME:
GIT_PERSONAL_ACCESS_TOKEN:
#!/bin/bash
set -eo pipefail
# env vars
GIT_UPSTREAM=${GIT_UPSTREAM:-"https://github.com/Superalgos/Superalgos.git"}
GIT_REPOSITORY_URL=${GIT_REPOSITORY_URL:-$GIT_UPSTREAM}
GIT_USERNAME=${GIT_USERNAME:-""}
GIT_PERSONAL_ACCESS_TOKEN=${GIT_PERSONAL_ACCESS_TOKEN:=""}
if [ "${GIT_USERNAME}" != "" ]; then
GIT_REPOSITORY_URL="https://github.com/${GIT_USERNAME}/Superalgos.git"
fi
if [ "${GIT_PERSONAL_ACCESS_TOKEN}" != "" ]; then
GIT_REPOSITORY_URL="https://strafe:${GIT_PERSONAL_ACCESS_TOKEN}@github.com/${GIT_USERNAME}/Superalgos.git"
fi
# check if code already exists
if [ -d "/app/Superalgos/.git" ]; then
# update code
cd /app/Superalgos
git checkout develop
if git remote | grep upstream ; then
git pull upstream develop
else
git pull
fi
else
# clone repo
git clone "${GIT_REPOSITORY_URL}" /app/Superalgos
if [ "${GIT_REPOSITORY_URL}" != "${GIT_UPSTREAM}" ]; then
git remote add upstream "${GIT_UPSTREAM}"
fi
fi
cd /app/Superalgos
# ensure node dependencies are up to date
node setup noShortcuts
# run the application
node platform minMemo noBrowser
FROM debian:latest
WORKDIR /app
COPY docker-entrypoint.sh /
RUN apt-get update \
&& apt-get upgrade -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y curl git bash zsh python3 \
&& curl -fsSL https://deb.nodesource.com/setup_17.x | bash - \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs gcc g++ make yarn \
&& chmod a+x /docker-entrypoint.sh
CMD [ "/docker-entrypoint.sh" ]
@ssplatt
Copy link
Author

ssplatt commented Nov 12, 2021

Updated to add an entrypoint script which automates cloning and updating of the Superalgos codebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment