Skip to content

The official digital platform for Gazeta CNVA. A modern content delivery system with a Go backend and SvelteKit frontend, deployed via Docker and GitHub Actions.

Notifications You must be signed in to change notification settings

lazarcloud/gazeta-cnva

Repository files navigation

Gazeta CNVA

Welcome to the Gazeta CNVA project! This repository contains the source code for the official Gazeta CNVA digital platform, a modern content delivery system built with a Go backend and a SvelteKit frontend.

Table of Contents

Gallery

Poem Submission Workflow

Form for Poems Poem in Google Docs Poem on Website
Form for Poems Poem in Google Docs Poem on Website

Website Homepage

Desktop Homepage Mobile Homepage
Website Desktop Homepage Website Mobile Homepage

Website Publications

Desktop Publications
Website Desktop Publications

Architecture Overview

The project is a monorepo composed of two main services:

  1. worker/ (Backend API): A Go application responsible for:

    • Periodically fetching new article submissions from a Google Form.
    • Downloading associated media (thumbnails, document content) from Google Drive and Google Docs.
    • Processing and caching this data.
    • Serving the content via a RESTful API.
  2. app/ (Frontend): A SvelteKit application that provides the user interface for reading articles. It consumes the data exposed by the Go backend.

Both applications are designed to be containerized with Docker and are deployed automatically via GitHub Actions.

Prerequisites

To work with this project, you will need the following installed:

  • Go (for the backend)
  • Node.js (for the frontend)
  • Docker (for building and running containers)

The deployment process relies on a self-hosted GitHub Actions runner tagged gazeta.

Configuration and Secrets

This project requires several secrets and configuration values to run. Do not hardcode these values in the source code. Use environment variables for local development and GitHub Secrets for deployment.

Google Cloud Service Account

The backend needs a Google Cloud Platform (GCP) Service Account to access Google Forms, Drive, and Docs.

  1. Create a Service Account in your GCP project.
  2. Enable the Google Drive API, Google Docs API, and Google Forms API for your project.
  3. Grant the Service Account the necessary IAM roles (e.g., Viewer or Editor) to access these services.
  4. Create a JSON key for the Service Account and download it.
  5. Share your Google Form, Google Drive folder(s), and any relevant Google Docs with the Service Account's email address (the client_email from the JSON key).

The following values from the JSON key and your setup are required.

For the Backend (worker/)

You must set these environment variables for the Go worker to run.

  • GCP_PRIVATE_KEY: The entire private key string from the JSON file, including -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----.
  • GCP_PRIVATE_KEY_ID: The private_key_id from the JSON file.
  • GCP_SERVICE_ACCOUNT_EMAIL: The client_email from the JSON file.
  • GCP_FORM_ID: The ID of the Google Form used for submissions.
  • API_URL: The public base URL of the API (e.g., https://api.gazetacnva.ro/). This is used to construct correct thumbnail URLs.

GitHub Actions Secrets

The following secrets must be configured in your GitHub repository settings (Settings > Secrets and variables > Actions) for the deployment workflows to succeed.

  • DOCKER_USERNAME: Your Docker Hub username.
  • DOCKER_PASSWORD: Your Docker Hub password or an access token.
  • GH_TOKEN: A GitHub Personal Access Token with read:packages scope. This is used during the Docker build to authenticate and download private Go modules.
  • GH_USERNAME: The GitHub username associated with the GH_TOKEN.

Running Locally

Backend API (Worker)

  1. Navigate to the worker directory: cd worker
  2. Set the required environment variables (see Configuration).
  3. Run the application: go run .
  4. The API will be available on http://localhost:8080.

Frontend App

  1. Navigate to the app directory: cd app
  2. Install dependencies: npm install
  3. Start the development server: npm run dev
  4. The application will be available on http://localhost:5173.

Deployment

Deployment is handled automatically by the GitHub Actions workflows defined in .github/workflows/.

  • build-gazeta-api.yml: Triggers on pushes to the worker/ directory. It builds the Go application, pushes a Docker image to Docker Hub, and then deploys it on the gazeta self-hosted runner.
  • build-gazeta-app.yml: Triggers on pushes to the app/ directory. It builds the SvelteKit application, pushes a Docker image to Docker Hub, and deploys it on the gazeta self-hosted runner.

The deployment steps on the runner involve:

  1. Stopping the old container.
  2. Removing the old container and image to save space.
  3. Starting a new container with the latest image from Docker Hub.

About

The official digital platform for Gazeta CNVA. A modern content delivery system with a Go backend and SvelteKit frontend, deployed via Docker and GitHub Actions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published