# Webservices App

This is an app I'm creating to visualise data I've created (in JSON form) describing my self-hosted (professional, volunteer, & personal) webservices.

## Credits

Developed by Dave Lane, [Open Source Technologist](https://oerfoundation.org/about/staff/#Dave_Lane) at the [OER Foundation](https://oerfoundation.org). Many thanks to support from the Foundation for this exploratory work!

## Installing the Webservices App

You can clone this repository from my [Forgejo instance](https://forge.magnificent.nz) using this command (replacing the latter webservices-app with your preferred directory name!):

    git clone https://forge.magnificent.nz/lightweight/webservices-app.git webservices-app

then

    cd webservices-app
    npm install

or, if you're using pnpm, use `pnpminstall` or for yarn, `yarn`. That will install the svelte and other javascript dependencies.


## Developing

Once you've created a project and installed dependencies, start a development server:

    npm run dev

# or start the server and open the app in a new browser tab

    npm run dev -- --open

## Building

To create a production version of your app:

    npm run build

You can preview the production build with `npm run preview`.

## Deployment

### To set up your SvelteKit project, ensure that your svelte.config.js file has this line:

    // import adapter from '@sveltejs/adapter-auto';
    import adapter from '@sveltejs/adapter-node';

and then run

    npm install

(which runs these)

    npm i -D @sveltejs/adapter-node
    npm i dotenv
    npm i --save-dev @sveltejs/enhanced-img

### To build a new image

    docker-compose build

You can push your new container to a docker container repository (I use my Forgejo instance!)

    docker push forge.magnificent.nz/lightweight/webservices-app:latest


### To deploy the new container

At the location you're running production, pull the updated container

    docker-compose pull

To start it up (and tail the logs - CTRL-C to quit out of the logs without affecting running container)

    docker-compose up -d && docker-compose logs -f

### To clear out an old image (if it's running)

    docker-compose down --remove-orphans --rmi 'all'
