Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add a nodejs tutorial #397

Merged
merged 8 commits into from
Nov 1, 2023
Merged

docs: add a nodejs tutorial #397

merged 8 commits into from
Nov 1, 2023

Conversation

tigarmo
Copy link
Collaborator

@tigarmo tigarmo commented Oct 30, 2023

The tutorial builds a simple "hello world" webapp and showcases using the npm plugin.

Fixes #369

  • Have you signed the CLA?

The tutorial builds a simple "hello world" webapp and showcases using a
package-repository to install newer node.

Fixes #369
@tigarmo tigarmo marked this pull request as ready for review October 30, 2023 19:25
@tigarmo tigarmo requested review from cjdcordeiro and lengau October 30, 2023 19:25
lengau
lengau previously requested changes Oct 30, 2023
Copy link
Contributor

@lengau lengau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this in a fresh Jammy VM:

ubuntu@racy-chinook:~$ sudo lxd init --auto
ubuntu@racy-chinook:~$ sudo snap install docker
docker 20.10.24 from Canonical✓ installed
ubuntu@racy-chinook:~$ sudo snap install rockcraft --edge --classic
rockcraft (edge) 0+git.36080ac from Sergio Schvezov ⭐ (sergiusens) installed
ubuntu@racy-chinook:~$ mkdir my_rock
ubuntu@racy-chinook:~$ cd my_rock/
ubuntu@racy-chinook:~/my_rock$ mkdir src
ubuntu@racy-chinook:~/my_rock$ nano src/package.json
ubuntu@racy-chinook:~/my_rock$ nano src/server.js
ubuntu@racy-chinook:~/my_rock$ nano rockcraft.yaml
ubuntu@racy-chinook:~/my_rock$ nano rockcraft.yaml
ubuntu@racy-chinook:~/my_rock$ rockcraft pack

At this point it failed because of Docker being inconsiderate on the network.

Using the standard workaround:

sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT

I got further, but I hadn't prepped sufficient disk space, so I'll have to come back to it.

It's probably out of scope for this tutorial, but should we add some documentation for troubleshooting this particular issue? It seems like it'd be pretty common for Rockcraft in particular.

docs/tutorials/node-app.rst Outdated Show resolved Hide resolved
docs/tutorials/node-app.rst Outdated Show resolved Hide resolved
docs/tutorials/node-app.rst Outdated Show resolved Hide resolved
@lengau
Copy link
Contributor

lengau commented Oct 30, 2023

With the suggested changes above, it works. (Including not separately installing skopeo.)

@tigarmo
Copy link
Collaborator Author

tigarmo commented Oct 31, 2023

@lengau while working on the review fixes I remembered that craft-parts has an npm plugin (doh), so in the interest of dogfooding it I updated the actual project to use it (it's now way simpler).

Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super neat! nice. thanks.

I only have one request, but it should be ok after that :)

docs/tutorials/node-app.rst Outdated Show resolved Hide resolved
@tigarmo tigarmo requested a review from lengau October 31, 2023 14:07
@tigarmo tigarmo requested review from cjdcordeiro and mr-cal October 31, 2023 17:56
Copy link
Collaborator

@mr-cal mr-cal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through the tutorial, worked great for me!

Copy link
Collaborator

@cjdcordeiro cjdcordeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the changes

@SamirPS
Copy link
Contributor

SamirPS commented Nov 1, 2023

hello,

i have a feeling about the tutorial, so the application is pretty simple ( good point) but i think we can explain a little more the section we add on the rockcraft.yaml.

One example is the service section, we can say " this part is defined to do this.... and if you application crash....".

WDYT?

@tigarmo
Copy link
Collaborator Author

tigarmo commented Nov 1, 2023

@SamirPS it's tough because a guideline of tutorials in Diátaxis is to keep explanations to a minimum, which is very hard to do sometimes. I already thought I put too much in but a tech author reviewed it and seems to be fine.

@SamirPS
Copy link
Contributor

SamirPS commented Nov 1, 2023

I checked with other people, and they said your tutorial is good. So I will only ask, if possible, could you please add the full rockcraft.yaml file at the end to help people to copy paste the yaml file.

@tigarmo
Copy link
Collaborator Author

tigarmo commented Nov 1, 2023

Sure. I had to update the notation to extract the snippets so that the whole file is "clean", but I put the whole rockcraft.yaml file at the end of the "Project Setup" section

@sergiusens sergiusens dismissed lengau’s stale review November 1, 2023 15:08

issues addressed

@sergiusens sergiusens merged commit b4dc8f1 into main Nov 1, 2023
7 of 9 checks passed
@sergiusens sergiusens deleted the CRAFT-2105-nodejs-tutorial branch November 1, 2023 15:12
@cjdcordeiro cjdcordeiro added the documentation Improvements or additions to documentation label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a nodejs tutorial
6 participants