Back

Tell `install` command to use environment variables

  • 0
  • Self Hosted
  • General
MatiasLGonzalez
14 Mar, 2023, 17:39

I'm trying to instantiate a appwrite server on GCP, VMs have the option to run a container on bootup, you can setup container environment variables and entrypoint command with its arguments, right now whenever I start the VM it's pulling the the image and running the install command but since this command is interactive and the vm is not giving it a STDIN, it's using default values for everything, so I was thinking if a feature could be added to the install command where, when giving the --env flag, it skips the interactive part and looks for environment variables matching the list of known environment values used by appwrite

TL;DR
User wants to use environment variables in the `install` command for Appwrite on a GCP VM. They suggest creating a script to download necessary files and update environment variables, then running `docker compose up -d`. User is looking for a more production-friendly approach. They provide a Docker command example. Goal is to instantiate Appwrite server on GCP VM using container deployment. Solution is to modify the `install` command to accept environment variables instead of being interactive.
MatiasLGonzalez
14 Mar, 2023, 17:40

Tell install command to use environment variables

Drake
14 Mar, 2023, 17:56

what exactly is your goal?

MatiasLGonzalez
14 Mar, 2023, 17:57

Instantiate appwrite on a GCP VM using the built in container deployment tool

Drake
14 Mar, 2023, 18:00

i don't know if that's really a good idea...if your goal is to have an image with appwrite, perhaps you can just have the docker files on the server already

MatiasLGonzalez
14 Mar, 2023, 18:12
TypeScript
docker run -it --rm \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
    -e _APP_ENV=production \
    -e _APP_DOMAIN=domain \
    -e _APP_OPENSSL_KEY_V1=very-secret-key \
    -e _APP_DOMAIN_TARGET=domain \
    -e _APP_SMTP_HOST=smtp.gmail.com \
    -e _APP_SMTP_PORT=465 \
    -e _APP_SMTP_SECURE=ssl \
    -e _APP_SMTP_USERNAME=username \
    -e _APP_SMTP_PASSWORD=password \
    --entrypoint="install" \
    appwrite/appwrite:1.2.1 \
    --env
MatiasLGonzalez
14 Mar, 2023, 18:14

I'm looking for something like this, so the install command runs non-interactively and I can use the container deployment of GCP's VMs

MatiasLGonzalez
14 Mar, 2023, 18:26

https://github.dev/appwrite/appwrite/blob/e8c74d7204258133a61db09ed518211170e751d9/app/tasks/install.php#L111 I believe this is done here, so instead of loading the /.env file, if the --env argument is passed, search in the environment for the variables

Drake
14 Mar, 2023, 18:35

again i really want to focus on what your end goal is...not trying to add env vars to the install command

MatiasLGonzalez
14 Mar, 2023, 18:37

Use this to run appwrite on a GCP VM

Drake
14 Mar, 2023, 18:40

in order to what?

MatiasLGonzalez
14 Mar, 2023, 18:42

Use appwrite on a GCP VM πŸ˜…

Drake
14 Mar, 2023, 18:44

you can do that by just running the install manually....so what is it do you really need?

MatiasLGonzalez
14 Mar, 2023, 18:46

Doing this would be a more production-friendly approach, instead of creating the VM, ssh-ing, running the docker command,

Drake
14 Mar, 2023, 18:47

so your end goal is to be able to start up a VM and already have appwrite installed

Drake
14 Mar, 2023, 18:47

what other ways can you configure a GCP VM? can you run a script on first launch?

MatiasLGonzalez
14 Mar, 2023, 18:49

Yes, it can run scripts at launch

Drake
14 Mar, 2023, 18:51

so you can write a script that:

  1. Creates appwrite folder
  2. Downloads this into the folder: https://appwrite.io/install/compose
  3. Downloads this into the folder: https://appwrite.io/install/env
  4. Updates any .env vars as necessary
  5. Runs docker compose up -d to startup appwrite
MatiasLGonzalez
14 Mar, 2023, 18:58

Hmm I still believe it would be more clean to just have the install command accept environment variables then creating a script with more moving parts, I have no problem working on that feature if you believe it has a chance of getting merged πŸ™‚

Drake
14 Mar, 2023, 19:03

i haven't seen any other requests like this so it doesn't seem like it would be very high in priority. you can submit an issue if you'd like

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more