You've just created a beautiful application and now you want to deploy it.
You may want to create your .DEB
Create the following structure (adapt the path /opt/sample-app as your need)
│ ├── control
│ └── postinst
mkdir sample-app/DEBIAN sample-app/opt/sample-app -p
The idea here is to recreate the structure of the target host that you want to create and/or copy files to.
Here we want to create the folder /opt/sample-app on the target server and copy our application inside it.
Next, copy your application into your sample-app/opt/sample-app folder
cp -r /home/user/sample-app sample-app/opt/sample-app/
Now, create a control file that gives some information about your application:
with the following content:
Maintainer: John Malkovich
Description: This app does some wonderful things
Fairly often you will need to run a script to tune the installation, like changing the permission or owner of files, create a database, modify a config file, etc...
To do so create another file into the DEBIAN folder called postinst
Then, write your script inside it:
chown www-data:www-data /opt/sample-app -R
Finally, create your .DEB package using the dpkg-deb command:
dpkg-deg --build sample-app
This will create the file sample-app.deb
You can then install it using:
apt install ./sample-app.deb
And remove it using:
apt remove sample-app
That's it, you've now created your own .DEB package that you can distribute easily like a PRO.