I am new to snapcraft and I am trying to build a snap for my application but I have been running into issues.
My application works with a postgres database, redis, hoops communicator for 3D assets and npm node_modules.
I am able to build the snap but it does not work as expected.
The goal is to be able to start my application with the node command ( node dist/workspaces/server/main
) but I get it error after installing and trying to run the snap. The error says “tslib module not found”. I ran unsquashfs against the snap and I can see the tslib module present in the node-modules folder. I want to release this app to the snapstore.
I must be doing something wrong.
I need help and clarification on some things.
- First, how can I package it to run effectively?
- Also, how can I build it to work with postgres and redis already running on my linux server? The reason for this question is that I have a .env file where I declare env variables for my nodejs app.
- Also, how can i build the snap to only install node_modules at installation time for the snap?
my snapcraft.yaml and .env files are available below. Thank you
name: my-app
base: core18
version: '0.1'
summary: node selfhosted web creator application
description: |
my-app is used to build interactive digital work instructions and manuals.
This is the web creator application for my-app.
grade: devel
confinement: devmode
parts:
my-app:
source: .
plugin: nodejs
nodejs-version: '16.13.0'
nodejs-package-manager: yarn
nodejs-yarn-version: 'v1.22.19'
stage-packages:
- redis
- postgresql
- libgl1
- libglu1-mesa
- libglvnd0
- libglx0
- libx11-6
- libxau6
- libxcb1
- libxdamage1
- libxdmcp6
- libxext6
- nodejs
- libxfixes3
hoops-converter:
plugin: nil
source: hoops_converter/
build-attributes: [keep-execstack]
override-build: |
apt install xvfb libsdl1.2-dev -y
export HOOPS_INSTALL_DIR=/usr/src
stage-packages:
- libgl1
- libglu1-mesa
- libglvnd0
- libglx0
- libx11-6
- libxau6
- libxcb1
- libxdamage1
- libxdmcp6
- libxext6
- libxfixes3
apps:
my-app:
command: bin/node
plugs: [network-bind, home, network]
and here is my .env file
PORT=4000
# credentials for sending emails through SMTP
SMTP_ACCESS_USER=
SMTP_ACCESS_PWD=
SMTP_ACCESS_HOST=
SMTP_ACCESS_PORT=587
REDIS_HOST=
REDIS_PORT=6379
REDIS_PASSWORD=
# Envision frontend URL (to configure idp realm correctly, and all the links sent in emails)
ENVISION_FRONTEND_URL=http://localhost:4200
# typeorm to connect to database ------
TYPEORM_DATABASE=envision
TYPEORM_HOST=
TYPEORM_USERNAME=
TYPEORM_PASSWORD=
TYPEORM_PORT=5432
# self host license keys
LICENSE_KEY=
# optional. Needed if SSL needs to be supported on app server side
PRIVATE_SSL_CERTIFICATE=
PUBLIC_SSL_CERTIFICATE=