Hi everyone,
I’m planning to use LXD to package and ship my software to remote servers. I made a bash file that packs the application code and installs necessary packages for a Django + angular application.
CONTAINER_NAME="django-server-$(date +"%Y-%m-%d--%I-%M-%p")"
lxc launch ubuntu-minimal:focal ${CONTAINER_NAME}
echo "Waiting container to wake up" #TODO make this into a while loop
sleep 10
echo "Placing files into the container"
lxc exec ${CONTAINER_NAME} -- sh -c "mkdir /home/ubuntu/django"
lxc exec ${CONTAINER_NAME} -- sh -c "mkdir /home/ubuntu/django/c2c"
lxc file push -r c2c/django_server/ ${CONTAINER_NAME}/home/ubuntu/django/c2c/
lxc file push -r c2c/C2CCommon/ ${CONTAINER_NAME}/home/ubuntu/django/c2c/
lxc file push Server.sh ${CONTAINER_NAME}/home/ubuntu/django/
lxc file push -r c2c/angular-webapp/dist/ ${CONTAINER_NAME}/var/www/
echo "Placed all files, now will install necessary packages"
lxc exec ${CONTAINER_NAME} -- sh -c "sudo apt-get update"
lxc exec ${CONTAINER_NAME} -- sh -c "sudo apt-get install -y python3-pip nginx"
lxc exec ${CONTAINER_NAME} -- sh -c "pip3 install -r /home/ubuntu/django/c2c/django_server/requirements.txt"
echo "Finished installation, now packing up the image"
lxc config set ${CONTAINER_NAME} image.description "django Server $(date +"%m/%d/%Y %I:%M%p")"
lxc config set ${CONTAINER_NAME} image.version "$(date +"%Y.%m.%d-%I.%M%p")"
lxc snapshot ${CONTAINER_NAME} current
lxc publish ${CONTAINER_NAME}/current --alias "django-server"
#lxc export ${CONTAINER_NAME} ./${CONTAINER_NAME}.tar.xz
here is my script if anyone wants to use it. However I’m having problems setting the image.version number and also the description. When I take the snapshot and publish it, the description from the base image is used, and the image.version and image.description that I set for the container is ignored.
Only command that I found to edit the image information is the following:
lxc image edit django-server
this spawns a vim console for me to manually edit the information, which is not usable for me because I want to automate all.
Does anyone know how to set the image information from bash?
Thanks.