Skip to content

Commit 4ecb4cb

Browse files
author
robertlestak
committed
add Dockerfile, support for default ADIF_URL and TITLE
1 parent fc0b117 commit 4ecb4cb

7 files changed

Lines changed: 102 additions & 0 deletions

File tree

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM nginx
2+
3+
WORKDIR /usr/share/nginx/html
4+
5+
ARG ADIF_URL
6+
ENV ADIF_URL=${ADIF_URL}
7+
ARG TITLE
8+
ENV TITLE=${TITLE}
9+
10+
COPY . /usr/share/nginx/html
11+
12+
RUN bash scripts/build.sh

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ To use this mode of the application, simply supply a `url` parameter to the inde
3333

3434
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.
3535

36+
When building with Docker, you can pass the `ADIF_URL` build arg to set the default URL to load. For example:
37+
38+
```bash
39+
docker buildx build --build-arg ADIF_URL=sample/short.adi -t qso-mapper .
40+
```
41+
42+
When set, the `ADIF_URL` takes precedence over the `url` parameter in the URL.
43+
3644
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.
3745

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

4654
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.
4755

56+
## Default ADIF File
57+
58+
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.
59+
60+
## Page Title
61+
62+
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:
63+
64+
```bash
65+
docker buildx build --build-arg TITLE="My QSO Mapper" -t qso-mapper .
66+
```
67+
4868
# Mentions
4969

5070
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!

deploy/k8s/deployment.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: qso-mapper
6+
namespace: default
7+
labels:
8+
app: qso-mapper
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app: qso-mapper
14+
template:
15+
metadata:
16+
labels:
17+
app: qso-mapper
18+
spec:
19+
containers:
20+
- name: qso-mapper
21+
image: registry.example.com/qso-mapper:latest
22+
imagePullPolicy: Always
23+
ports:
24+
- containerPort: 80
25+
name: http
26+
resources:
27+
requests:
28+
memory: "64Mi"
29+
cpu: "250m"
30+
limits:
31+
memory: "128Mi"
32+
cpu: "500m"

deploy/k8s/service.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: qso-mapper
6+
namespace: default
7+
labels:
8+
app: qso-mapper
9+
spec:
10+
type: ClusterIP
11+
selector:
12+
app: qso-mapper
13+
ports:
14+
- protocol: TCP
15+
port: 80
16+
targetPort: 80

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
crossorigin=""></script>
4242
<script src="leaflet-map.js"></script>
4343

44+
<script>
45+
let ADIF_URL = '';
46+
</script>
47+
4448
<!-- The main code for this application -->
4549
<script src="qso-mapper.js"></script>
4650
</head>

qso-mapper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function initQsoMapper() {
4545
// https://stephenhouser.com/qso-mapper?url=sample/short.adi
4646
// https://stephenhouser.com/qso-mapper?url=https://stephenhouser.com/qso-mapper/sample/short.adi
4747
var url = getQueryVariable('url');
48+
if (ADIF_URL !== null && ADIF_URL !== '') {
49+
url = ADIF_URL;
50+
}
4851
if (url !== null) {
4952
disableFileUpload();
5053
loadQSOsFromURL(url);

scripts/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
if [[ ! -z "$ADIF_URL" ]]; then
4+
cp index.html index.html.bak && \
5+
sed -e "s,let ADIF_URL = '';,let ADIF_URL = '$ADIF_URL';," \
6+
index.html > index.html.tmp && \
7+
mv index.html.tmp index.html
8+
fi
9+
10+
if [[ ! -z "$TITLE" ]]; then
11+
cp index.html index.html.bak && \
12+
sed -e "s,<title>QSO/ADIF Mapper<\/title>,<title>$TITLE<\/title>," \
13+
index.html > index.html.tmp && \
14+
mv index.html.tmp index.html
15+
fi

0 commit comments

Comments
 (0)