Skip to content

Commit f5a69fe

Browse files
author
root
committed
Styling and build improvements
- Use multistage build, copied from fork https://github.com/tandeday/version99 - Added styling to html - Typo in generated pom
1 parent f37cf2e commit f5a69fe

8 files changed

+59
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
version99
2+
version99.exe

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Based on https://www.cloudreach.com/en/technical-blog/containerize-this-how-to-build-golang-dockerfiles/
2+
#
3+
# First create main in a rich build environment
4+
5+
FROM golang:alpine as builder
6+
RUN mkdir /src
7+
ADD src /src
8+
WORKDIR /src
9+
RUN go mod init grons.nl/version99 && go build -o version99
10+
11+
# then copy it to a small image.
12+
13+
FROM alpine
14+
MAINTAINER Erik van Oosten, [email protected]
15+
RUN adduser -S -D -H -h /app appuser
16+
USER appuser
17+
COPY --from=builder /src/version99 /app/
18+
WORKDIR /app
19+
CMD ["./version99"]
20+
EXPOSE 8080
21+

README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ For example the following links will give an [empty jar](http://version99.grons.
1010

1111
The [original Ruby/Camping application](https://github.com/erikvanoosten/version99/blob/master/version99.rb) was ported to Go by my colleague Frank Schroeders.
1212

13-
Build it as follows:
13+
Build it natively as follows:
1414

15-
go build
15+
cd src
16+
go mod init example/version99
17+
go build -o version99
18+
19+
Build and run it in a modern Docker as follows:
20+
21+
docker build -t version99:latest .
22+
docker run -it --rm -p 8080:8080 version99:latest
1623

1724
This service is running on http://version99.grons.nl. However, I encourage you to run this service yourself as bandwidth to my machine is limited.
1825

favicon.ico

-318 Bytes
Binary file not shown.

favicon.png

113 Bytes
Loading

helper.go src/helper.go

File renamed without changes.

http.go src/http.go

+28-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
const (
1010
INFO_URL = "http://day-to-day-stuff.blogspot.com/2007/10/announcement-version-99-does-not-exist.html"
11-
FAVICON_ICO = "AAABAAEAEBAQAAAAAAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAD/AAAA////AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEREQERERAAAAARAAABEAAREREBEREQABEAEQEQARAAERERAREREAAAAAAAAAAAAAAAAAAAAAACIiIiIiIiIiIiIiIiIiIiIiIiIhEiIiIiIiIhERIiIiIiIhEiESIiIiIiESIRIiIiIiIiIiIiIiIiIiIiIiIiIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
11+
FAVICON_PNG = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAOElEQVR4AWP4z0AaolwDGCCzKdeAiZAA0X4AA5p4mjCiix3/MQEOQTDCEfSYguTbQDgCKLeBJAQA5cd6lDERP0gAAAAASUVORK5CYII="
1212
EMPTY_JAR = "UEsDBAoAAAAAAME+SDiyfwLuGQAAABkAAAAUAAQATUVUQS1JTkYvTUFOSUZFU1QuTUb+ygAATWFuaWZlc3QtVmVyc2lvbjogMS4wDQoNClBLAQIKAAoAAAAAAME+SDiyfwLuGQAAABkAAAAUAAQAAAAAAAAAAAAAAAAAAABNRVRBLUlORi9NQU5JRkVTVC5NRv7KAABQSwUGAAAAAAEAAQBGAAAATwAAAAAA"
1313

1414
POM_XML = `<?xml version="1.0" encoding="iso-8859-1"?>
@@ -19,7 +19,8 @@ const (
1919
<name>{{.Name}}</name>
2020
<version>99.0-does-not-exist</version>
2121
<description>
22-
This is a generated pom. Version 99.0-does-not-exist is a dummy implementation with actually does nothing and has no dependencies.
22+
This is a generated pom.
23+
Version 99.0-does-not-exist is a dummy implementation which actually does nothing and has no dependencies.
2324
VERSION 99.0-does-not-exist IS NOT IN ANY WAY AFFILIATED WITH THE ORIGINAL DEVELOPERS of {{.GroupId}}.
2425
</description>
2526
<url>{{.InfoURL}}</url>
@@ -28,9 +29,16 @@ const (
2829
INDEX_HTML = `<html>
2930
<head>
3031
<title>Version 99 Does Not Exist</title>
32+
<style>
33+
html { font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; }
34+
body { padding: 5px; max-width: 550px; }
35+
h1 { font-size: 120%; }
36+
img { width:1em; height:1em; position:relative; top:2px; }
37+
</style>
38+
<link rel="icon" href="/favicon.png" type="image/png">
3139
</head>
3240
<body>
33-
<h1>Version 99 Does Not Exist</h1>
41+
<h1><img src="/favicon.png"> Version 99 Does Not Exist</h1>
3442
<p>Please see <a href="http://day-to-day-stuff.blogspot.com/2007/10/announcement-version-99-does-not-exist.html">my blog</a> to read why I created Version 99 Does Not Exist and its predecessor no-commons-logging.</p>
3543
<p>Version 99 Does Not Exist emulates a Maven 2 repository and serves empty jars for any valid package that has version number <i>99.0-does-not-exist</i>. It also generates poms, <span style="text-decoration: line-through">metadata files</span> (removed since 2.0) and of course the appropriate hashes.</p>
3644
<p>For example the following links will give an <a href="http://version99.grons.nl/mvn2/commons-logging/commons-logging/99.0-does-not-exist/commons-logging-99.0-does-not-exist.jar">empty jar</a>, its <a href="http://version99.grons.nl/mvn2/commons-logging/commons-logging/99.0-does-not-exist/commons-logging-99.0-does-not-exist.pom">pom</a> and the <a href="http://version99.grons.nl/mvn2/commons-logging/commons-logging/maven-metadata.xml"><span style="text-decoration: line-through">maven metadata</span></a> for commons-logging.</p>
@@ -39,9 +47,20 @@ const (
3947
</html>`
4048

4149
NOT_FOUND_HTML = `<html>
50+
<head>
51+
<title>Version 99 Does Not Exist</title>
52+
<style>
53+
html { font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif; }
54+
body { padding: 5px; max-width: 550px; }
55+
h1 { font-size: 120%; }
56+
h1 > a { text-decoration: inherit; color: inherit; }
57+
img { width:1em; height:1em; position:relative; top:2px; }
58+
</style>
59+
<link rel="icon" href="/favicon.png" type="image/png">
60+
</head>
4261
<body>
43-
<h1>Version 99 Does Not Exist (Error 404)</h1>
44-
<h2>Not Found: {{.URL}}</h2>
62+
<h1><a href="/"><img src="/favicon.png"> Version 99 Does Not Exist - Error 404</a></h1>
63+
<h2>404 Not Found: {{.URL}}</h2>
4564
<p>
4665
<a href="{{.InfoURL}}">Version 99 Does Not Exist</a> is a virtual Maven2 repository.
4766
It generates jars and poms for any artifact with version <tt>99.0-does-not-exist</tt>.
@@ -74,7 +93,7 @@ var (
7493
notFoundTemplate = template.Must(template.New("notFound").Parse(NOT_FOUND_HTML))
7594
pomTemplate = template.Must(template.New("pom").Parse(POM_XML))
7695
emptyJar = mustBase64Decode(EMPTY_JAR)
77-
favicon = mustBase64Decode(FAVICON_ICO)
96+
favicon = mustBase64Decode(FAVICON_PNG)
7897
)
7998

8099
// --------------------------------------------------------------------
@@ -90,8 +109,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
90109
return
91110
}
92111

93-
if r.RequestURI == "/favicon.ico" {
94-
sendOK(favicon, "image/x-icon", w, r)
112+
if r.RequestURI == "/favicon.png" {
113+
sendOK(favicon, "image/png", w, r)
95114
return
96115
}
97116

@@ -131,3 +150,4 @@ func handler(w http.ResponseWriter, r *http.Request) {
131150

132151
sendNotFound(w, r)
133152
}
153+

main.go src/main.go

File renamed without changes.

0 commit comments

Comments
 (0)