This project provides a web app that performs CRUD API operations with the gin web framework and stores results in a postgres database.
You can download the compiled binary as an artifact from the GitHub Actions CI/CD workflow and execute it on your Linux machine.
A container form to implement this application is available.
-
Go to the Package Tab: Go to the package tab
-
Download from ghcr: Make sure to use version from the package tab, but an example download would be
docker pull ghcr.io/skylarhoughtongithub/go-book-chameleon:sha256-a9257b5693babf355f6f931a4af4b11b1943c8b3fedd8868895c963b920cd8d3
And then run in the desired container engine of your choice.
To download the latest artifact from the GitHub Actions workflow, follow these steps:
-
Go to the Actions Tab:
- Navigate to the Actions tab in this repository.
-
Select the Latest Workflow Run:
- Click on the most recent workflow run. You’ll see a list of jobs that were executed.
-
Find the Artifacts Section:
- Scroll down to the "Artifacts" section at the bottom of the job details.
-
Download the Artifact:
- Click on the artifact name (e.g.,
skylab-book-chaemeleon.zip
) to download it to your machine.
- Click on the artifact name (e.g.,
Once you have downloaded the artifact, follow these steps to execute the binary:
-
Extract the Artifact:
- Navigate to the directory where you downloaded the artifact and extract it. If it's a ZIP file, you can use the following command:
unzip skylab-book-chameleon.zip
- Navigate to the directory where you downloaded the artifact and extract it. If it's a ZIP file, you can use the following command:
-
Make the Binary Executable:
- Change to the directory containing the binary and make it executable:
chmod +x skylab-book-chameleon
- Change to the directory containing the binary and make it executable:
To start the web app, run:
./skylab-book-chameleon
With no postgres connection established, you should get an error:
Failed to connect to database: dial tcp [::1]:5432: connect: connection refused
Make sure ./configs/config.yml
has the proper database connection and authentication details configured.
When it connects correctly, it should tell you the tables were present or created and the server has started on the requested port:
Table created or already exists.
Starting server on :8080
At this point you can start submitting requests!
[GIN] 2024/09/22 - 20:55:06 | 200 | 100.5774ms | ::1 | GET "/static/"
[GIN] 2024/09/22 - 20:55:06 | 304 | 11.7073ms | ::1 | GET "/static/styles.css"
[GIN] 2024/09/22 - 20:55:06 | 304 | 35.0204ms | ::1 | GET "/static/books.js"
[GIN] 2024/09/22 - 20:55:06 | 200 | 23.6815ms | ::1 | GET "/api/books"
[GIN] 2024/09/22 - 20:55:07 | 404 | 0s | ::1 | GET "/favicon.ico"
[GIN] 2024/09/22 - 20:55:14 | 304 | 505.6µs | ::1 | GET "/static/"
[GIN] 2024/09/22 - 20:55:14 | 200 | 13.4633ms | ::1 | GET "/api/books"
[GIN] 2024/09/22 - 20:56:26 | 201 | 16.8652ms | ::1 | POST "/api/books"
[GIN] 2024/09/22 - 20:56:26 | 200 | 3.6384ms | ::1 | GET "/api/books"