Skip to content

Commit

Permalink
add Dockerfile, support for default ADIF_URL and TITLE
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlestak committed Oct 27, 2024
1 parent fc0b117 commit 16441ed
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM nginx

WORKDIR /usr/share/nginx/html

ARG ADIF_URL
ENV ADIF_URL=${ADIF_URL}
ARG TITLE
ENV TITLE=${TITLE}
ARG BRAND
ENV BRAND=${BRAND}

COPY . /usr/share/nginx/html

RUN bash scripts/build.sh
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ To use this mode of the application, simply supply a `url` parameter to the inde

When using this variant of the application, the `Select file...` and `Reset` are disabled and you are only able to load a single [ADIF file][adif] URL.

When building with Docker, you can pass the `ADIF_URL` build arg to set the default URL to load. For example:

```bash
docker buildx build --build-arg ADIF_URL=sample/short.adi -t qso-mapper .
```

When set, the `ADIF_URL` takes precedence over the `url` parameter in the URL.

You should consider forking the repository if you intend on using this long-term. That way you can change the map tile *access token* to your own token making sure it works for you long-term. If you don't fork and use your own, you run the risk of what I have here running out of quota and not working at all for you.

# Customization
Expand All @@ -45,6 +53,26 @@ As noted above the default map provider is [OpenStreetMap][osm]. The `mapTiles`

If you want to use a different marker icon, take a look in `leaflet-map.js` at the function `createMarker()`. There is a brief bit of commented out code that will make a small blue marker from an icon in the `icons` directory.

## Default ADIF File

If you want to set a default ADIF file to load when the application starts, you can set the `ADIF_URL` variable in `index.html`. This overrides the `url` parameter, making the app load only the file specified.

## Page Title

By default, the page title is `QSO/ADIF Mapper`. If using the `scripts/build.sh` script (the default in Docker) you can pass the `TITLE` environment variable to set the page title. For example:

```bash
docker buildx build --build-arg TITLE="My QSO Mapper" -t qso-mapper .
```

## Brand

By default, the brand (the title in the top left of the page) is `QSO Mapper`. If using the `scripts/build.sh` script (the default in Docker) you can pass the `BRAND` environment variable to set the brand. For example:

```bash
docker buildx build --build-arg BRAND="My QSO Mapper" -t qso-mapper .
```

# Mentions

I wanted to thank the [Linux in the Ham Shack](http://lhspodcast.info) podcast folks, who picked up on my pushing to [GitHub](https://github.com) and mentioned the project in their [Party Like it's 1499](http://lhspodcast.info/2018/10/lhs-episode-251-party-like-its-1499/comment-page-1/#comment-689046) episode. As an ex-scoutmaster for a Boy Scout troop, I think it would be an excellent idea to use QSO Mapper to show your [Jamboree on the Air](https://www.scouting.org/jota/) contacts!
Expand Down
32 changes: 32 additions & 0 deletions deploy/k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: qso-mapper
namespace: default
labels:
app: qso-mapper
spec:
replicas: 1
selector:
matchLabels:
app: qso-mapper
template:
metadata:
labels:
app: qso-mapper
spec:
containers:
- name: qso-mapper
image: registry.example.com/qso-mapper:latest
imagePullPolicy: Always
ports:
- containerPort: 80
name: http
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
16 changes: 16 additions & 0 deletions deploy/k8s/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
name: qso-mapper
namespace: default
labels:
app: qso-mapper
spec:
type: ClusterIP
selector:
app: qso-mapper
ports:
- protocol: TCP
port: 80
targetPort: 80
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
crossorigin=""></script>
<script src="leaflet-map.js"></script>

<script>
let ADIF_URL = '';
</script>

<!-- The main code for this application -->
<script src="qso-mapper.js"></script>
</head>
Expand Down
3 changes: 3 additions & 0 deletions qso-mapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function initQsoMapper() {
// https://stephenhouser.com/qso-mapper?url=sample/short.adi
// https://stephenhouser.com/qso-mapper?url=https://stephenhouser.com/qso-mapper/sample/short.adi
var url = getQueryVariable('url');
if (ADIF_URL !== null && ADIF_URL !== '') {
url = ADIF_URL;
}
if (url !== null) {
disableFileUpload();
loadQSOsFromURL(url);
Expand Down
22 changes: 22 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if [[ ! -z "$ADIF_URL" ]]; then
cp index.html index.html.bak && \
sed -e "s,let ADIF_URL = '';,let ADIF_URL = '$ADIF_URL';," \
index.html > index.html.tmp && \
mv index.html.tmp index.html
fi

if [[ ! -z "$TITLE" ]]; then
cp index.html index.html.bak && \
sed -e "s,<title>QSO/ADIF Mapper<\/title>,<title>$TITLE<\/title>," \
index.html > index.html.tmp && \
mv index.html.tmp index.html
fi

if [[ ! -z "$BRAND" ]]; then
cp index.html index.html.bak && \
sed -e "s,QSO Mapper,$BRAND," \
index.html > index.html.tmp && \
mv index.html.tmp index.html
fi

0 comments on commit 16441ed

Please sign in to comment.