threefoldtech / test_feedback

Apache License 2.0
3 stars 0 forks source link

Make environment variables available in flist container #289

Closed LennertDefauw1 closed 2 years ago

LennertDefauw1 commented 2 years ago

Currently deploying an flist with the grid3 typescript client.

Giving environment variables to the VM

image

Logging in with ssh to the public IP, getting the environement variables returns me to

image

No pregiven env vars were found. Environement variables are availble in your entrypoint, but they should be available anywhere. Trying to EXPORT USER_ID = "lennertapp2" inside my entrypoint script didnt work either.

coesensbert commented 2 years ago

Can't help with that but I wonder what flist did you use?

LennertDefauw1 commented 2 years ago

I am using the following flist: https://hub.grid.tf/lennertapp2.3bot/threefoldjimber-ssh-latest.flist

LennertDefauw1 commented 2 years ago

This is needed to have a generic flist where we can just pass through environment variables for a Vue3 NodeJS application

coesensbert commented 2 years ago

Is this a full vm or container based flist?

LennertDefauw1 commented 2 years ago

This is the Dockerfile:

FROM ubuntu:20.04
RUN echo deb http://be.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse >> /etc/apt/sources.list
RUN apt-get update && DEBIAN_FRONTEND=noninteractive TZ=Europe/Belgium apt-get install -y openssh-client openssh-server && rm -rf /var/lib/apt/lists/*
COPY init.sh /init.sh
RUN chmod +x /init.sh
ENTRYPOINT ["/init.sh"]

with init.sh:

#!/bin/bash

export TEST='TEST'
export USER_ID=$USER_ID

mkdir -p ~/.ssh
mkdir -p /var/run/sshd
echo $SSH_KEY >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
exec /usr/sbin/sshd -D
xmonader commented 2 years ago

the env vars are available to process 1 e.g

image

image