Skip to content

Commit

Permalink
Merge pull request #26 from term-world/api-container
Browse files Browse the repository at this point in the history
added api-container folder
  • Loading branch information
dluman committed May 20, 2024
2 parents 8193039 + 11f1663 commit fcfb173
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
18 changes: 18 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,21 @@ jobs:
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/topia
docker tag topia:slim $IMAGE_ID:slim
docker push $IMAGE_ID:slim
build-topia-slim:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Build image
run: |
cd dockerfiles/topia/api-container
docker build -f Dockerfile . -t topia:api-container
- name: Log in to container registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Publish image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/topia
docker tag topia:slim $IMAGE_ID:slim
docker push $IMAGE_ID:slim
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
Binary file added dockerfiles/.DS_Store
Binary file not shown.
Binary file added dockerfiles/topia/.DS_Store
Binary file not shown.
72 changes: 72 additions & 0 deletions dockerfiles/topia/api-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
FROM ubuntu

ENV DEBIAN_FRONTEND=noninteractive

RUN echo "America/New_York" > /etc/timezone

RUN apt-get update && apt-get install -y \
jq \
git \
curl \
nano \
sudo \
tree \
wget \
tzdata \
python3 \
sqlite3 \
python3-dev \
python3-pip \
libcairo2-dev \
python3.10-venv \
python-is-python3

RUN python -m pip install \
rich \
typer \
pillow \
pyyaml \
openai \
arglite \
seaborn \
requests \
matplotlib \
gatorgrader \
python-dotenv

ARG GITHUB_CDN=https://raw.githubusercontent.com/term-world/world-container/main

RUN curl -fsSL $GITHUB_CDN/scripts/direvents.sh | cat >> /etc/bash.bashrc
RUN curl -fsSL $GITHUB_CDN/scripts/gginstall.sh | sh
RUN curl -fsSL $GITHUB_CDN/scripts/utilinstall.sh | sh

# chompchain install: for future edge builds

#RUN git clone https://github.com/term-world/chompchain-wallet.git
#RUN cd chompchain-wallet && python -m pip install .

#RUN git clone https://github.com/term-world/chompchain.git
#RUN cd chompchain && python -m pip install .

#RUN git clone https://github.com/term-world/falcon-sign.git
#RUN cd falcon-sign && python -m pip install .

RUN curl -fsSL https://code-server.dev/install.sh | sh

RUN curl -fsSL https://api.github.com/repos/term-world/term-world-theme/releases/latest | wget $(jq -r ".assets[].browser_download_url")
RUN curl -fsSl https://api.github.com/repos/term-world/term-launcher/releases/latest | wget $(jq -r ".assets[].browser_download_url")

RUN wget $GITHUB_CDN/extensions/bierner.markdown-checkbox-0.4.0.vsix
RUN wget $GITHUB_CDN/scripts/motd

RUN cp motd /etc/motd

RUN echo "cat /etc/motd" >> /etc/bash.bashrc

RUN wget $GITHUB_CDN/scripts/world-cmd.sh
RUN cp world-cmd.sh /etc/profile.d/world-cmd.sh

ADD entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh

ENTRYPOINT /entrypoint.sh
52 changes: 52 additions & 0 deletions dockerfiles/topia/api-container/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

ENV_MARKET="/etc/profile.d/world-market.sh"
ENV_HELPER="/etc/profile.d/world-helper.sh"

touch $ENV_MARKET
touch $ENV_HELPER

echo "#!/bin/bash" >> $ENV_MARKET
echo "export WORLD_NAME=topia"
echo "export DB_HOST=$DB_HOST" >> $ENV_MARKET
echo "export DB_USER=$DB_USER" >> $ENV_MARKET
echo "export DB_PASS=$DB_PASS" >> $ENV_MARKET

echo "export OPEN_AI_KEY=$OPEN_AI_KEY" >> $ENV_HELPER
echo "export OPEN_AI_ORG=$OPEN_AI_ORG" >> $ENV_HELPER

ln -s /world/.python/bin/python3 /usr/bin/python

useradd -u $VS_USER_ID $VS_USER -s /bin/bash
groupadd -g $GID $DISTRICT

usermod -g $GID $VS_USER

usermod -aG $DISTRICT $VS_USER
usermod -d /world/city/$DISTRICT/$VS_USER $VS_USER

cd /world

chown root:$DISTRICT city/$DISTRICT
chown -R $VS_USER:$VS_USER city/$DISTRICT/$VS_USER

export INV_PATH="~/.inv"
export INV_REGISTRY=".registry"

mkdir -p city/$DISTRICT/$VS_USER/.inv

INV_FILE="city/$DISTRICT/$VS_USER/.inv/.registry"

if [ -f $INV_FILE ]; then
echo "INVENTORY FILE EXISTS!"
else
echo "{}" >> $INV_FILE
fi

sudo -i -u $VS_USER source /etc/profile.d/world-cmd.sh
sudo -i -u $VS_USER source /etc/profile.d/world-market.sh

sudo -i -u $VS_USER code-server --install-extension /term-world-theme.vsix
sudo -i -u $VS_USER code-server --install-extension /term-world-launcher.vsix
sudo -i -u $VS_USER code-server --install-extension /bierner.markdown-checkbox-0.4.0.vsix
sudo -i -u $VS_USER code-server --disable-getting-started-override

0 comments on commit fcfb173

Please sign in to comment.