Skip to content

Commit

Permalink
Rebuild app. Removed snapcraft.yaml. Upgraded Alpine. Updated GitHub …
Browse files Browse the repository at this point in the history
…Actions
  • Loading branch information
glenndehaan committed Jun 4, 2024
1 parent 447e152 commit aeeadec
Show file tree
Hide file tree
Showing 29 changed files with 1,256 additions and 3,933 deletions.
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ node_modules/
npm-debug.log

# App
config.json
*.log
app/config/reports/*.json
app/reports/*.json
31 changes: 31 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# When the workflow succeeds the package will be published to docker hub

name: Publish Docker Image

on:
push:
branches:
- 'master'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: true
tags: glenndehaan/devinfo:latest
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ node_modules/
npm-debug.log

# App
config.json
*.log
app/config/reports/*.json
app/reports/*.json
74 changes: 64 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,76 @@
FROM alpine:3.14
#=====================================================
# Build Stage
#=====================================================

#
# Define OS
#
FROM alpine:3.20 AS dependencies

#
# Basic OS management
#

# Install packages
RUN apk add --no-cache nodejs npm

# Create app directory
WORKDIR /usr/app
#
# Require app
#

# Create config volume
VOLUME ["/var/app"]
# Create app directory
WORKDIR /app

# Bundle app source
COPY . .
# Bundle package.json and package-lock.json
COPY ./package.json ./package-lock.json ./

# Install dependencies
RUN npm ci --only=production
RUN npm ci --only=production && npm cache clean --force

#=====================================================
# Image Stage
#=====================================================

#
# Define OS
#
FROM alpine:3.20

#
# Basic OS management
#

# Install packages
RUN apk add --no-cache dumb-init nodejs

#
# Require app
#

# Create app directory
WORKDIR /app

#
# Setup app
#

# Expose app
EXPOSE 4289
EXPOSE 3000

# Set node env
ENV NODE_ENV=production

# Setup healthcheck
HEALTHCHECK --interval=10s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:3000/_health || exit 1

# Run app
CMD ["node", "./app/bundle-docker.js"]
CMD ["dumb-init", "node", "/app/server.js"]

#
# Bundle app
#

# Bundle from build image
COPY --from=dependencies /app/node_modules ./node_modules
COPY app .
96 changes: 21 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,41 @@

A system/browser info page used by developers to check browser specifics

[![Snap Status](https://build.snapcraft.io/badge/glenndehaan/devinfo.svg)](https://build.snapcraft.io/user/glenndehaan/devinfo) [![devinfo](https://snapcraft.io//devinfo/badge.svg)](https://snapcraft.io/devinfo) [![Build Status](https://img.shields.io/docker/cloud/build/glenndehaan/devinfo.svg)](https://hub.docker.com/r/glenndehaan/devinfo) [![Build Status](https://img.shields.io/docker/cloud/automated/glenndehaan/devinfo.svg)](https://hub.docker.com/r/glenndehaan/devinfo)
[![Image Size](https://img.shields.io/docker/image-size/glenndehaan/devinfo)](https://hub.docker.com/r/glenndehaan/devinfo)

## Structure
* Express.JS
* EJS
* CSS
* Simple Node Logger
* JS Logger
* Express User Agent
* Check IP

## Basic Usage
### Snapcraft
#### Install
- Install the app via snapd:

[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-white.svg)](https://snapcraft.io/devinfo)

- Open up a browser and go to http://127.0.0.1:4289

#### Config
The config can be found here:
```
/var/snap/devinfo/common/config.json
```

#### Log
The log can be found here:
```
/var/snap/devinfo/common/server.log
```

Additional snap logs can be accessed by running this command:
```
sudo journalctl -fu snap.devinfo.devinfo-server
```

#### Service
Snap installs a service by default. To get the status of the app run this command:
```
service snap.devinfo.devinfo-server status
```
## Development Usage
- Install NodeJS 20.0 or higher
- Run `npm install` in the root project folder
- Run `npm run dev` in the root project folder

To restart the app:
```
service snap.devinfo.devinfo-server restart
```
Then open up a webbrowser and go to: `http://localhost:3000`

### Docker
- Download the `docker-compose.yml` file from the repo
- Place the file on your server
- Run `docker-compose up`
- Open up a browser and go to http://127.0.0.1:4289
## Docker

#### Config
The config can be found here:
```
./devinfo_docker_config/config.json
```
- Code from master is build by Docker Hub
- Builds can be pulled by using this command: `docker pull glenndehaan/devinfo`
- An example docker compose file can be found below:

#### Log
The log can be found here:
```
./devinfo_docker_config/server.log
```yaml
version: '3'
services:
app:
image: glenndehaan/devinfo
ports:
- "3000:3000"
environment:
# Sets the application Log Level (Valid Options: error|warn|info|debug|trace)
LOG_LEVEL: 'info'
```
## Development Usage
- Install NodeJS 8.0 or higher
- Run `npm install` in the root project folder
- Run `npm run dev` in the root project folder

Then open up a webbrowser and go to: `http://localhost:4289`

## Reports
After a report has been generated the url should look something like this:
```
Expand All @@ -88,23 +51,6 @@ https://devinfo.example.com/report/76468dd1-e20c-4085-831b-672489ca886a/raw

> This data could also be integrated into other applications that might need it
## Customization
### Logo
By updating the config you are able to override the default logo:
```json
{
"logo": "<img src='data:image/png;base64,........'/>"
}
```

### Footer
By updating the config you are able to override the default footer:
```json
{
"footer": "Hello World!"
}
```

## License

MIT
1 change: 0 additions & 1 deletion _scripts/config/config.build.json

This file was deleted.

2 changes: 0 additions & 2 deletions app/bundle-docker.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/bundle-snapcraft.js

This file was deleted.

56 changes: 0 additions & 56 deletions app/config/index.js

This file was deleted.

61 changes: 0 additions & 61 deletions app/controllers/BaseController.js

This file was deleted.

Loading

0 comments on commit aeeadec

Please sign in to comment.