Difference between revisions of "Product Opener - How to use gitpod"

From Open Food Facts wiki
Jump to navigation Jump to search
(Created page with "== Introduction == If your computer performances are restricting you to make developments, you can use Gitpod. Gitpod allows you to do the devs on an ephemeral environment. It...")
(No difference)

Revision as of 14:42, 15 January 2023

Introduction

If your computer performances are restricting you to make developments, you can use Gitpod. Gitpod allows you to do the devs on an ephemeral environment. It is free for a maximum of 500 credits or 50 hours per months (https://www.gitpod.io/pricing).

Setup environment

Connect GitHub and Gitpod

When you use Gitpod, you allow Gitpod to use your GitHub account.

In GitHub, you can review (and revoke if you stop using Gitpod) the access granted to Gitpod: click on your avatar on top right of the screen, then, Settings. In the left panel, under Integrations, click on Applications, then, Authorized OAuth Apps.

In Gitpod side, you can also update what Gitpod is allowed to do with your GitHub account: click on your avatar on top right of the screen, then, Settings. In the left panel, click on Integrations. The line for GitHub should be green. At the end of this line, click on the three dots, then, Edit Permissions. If you want to create a pull request via Gitpod, you need to grant public_repo access.

Open the website from your local machine

If you need to see the website during your developments, you cannot simply do it using your web browser because the code is not running on your machine! To be able to open the website on your machine, you have to connect from your machine to the server where the code is running. The connection is made by ssh. It needs an ssh-key. Gitpods explains how to do so, just follow these instructions: https://www.gitpod.io/docs/configure/user-settings/ssh#create-an-ssh-key.

To connect via ssh, go to GitHub workspaces page, on the line of your workspace click on the three dots, then, Connect via SSH, copy the command. Add "-L 80:localhost:80" and run it in a terminal. The command looks like: ssh -L 80:localhost:80 'openfoodfac-openfoodfac-blablabla.gitpod.io'

Remark: for some Linux distributions, the port 80 is reserved. A workaround is to switch to port 8080: in gitpod, open the .env file and replace the line PRODUCT_OPENER_PORT=80 by PRODUCT_OPENER_PORT=8080, then replace -L 80:localhost:80 by -L 8080:localhost:8080. Rollback the changes on .env before to make a pull request!

Now, you can open http://world.openfoodfacts.localhost:80. Create an account to be able to edit products.

Commands

Once you made devs and want to apply changes and see them on the website, you can run:

$ docker-compose restart

$ make up


If you face some difficulties, you can always look at the logs (use ctrl + c, to quit):

$ make log

$ make tail

At the end of your devs, before to open a pull request, run the following command:

$ make checks

References

Refer to the documentation in the repository for more information: https://github.com/openfoodfacts/openfoodfacts-server/tree/main/docs/how-to-guides