Skip to content

Commit a67519a

Browse files
authored
Make the background images move (#339)
* Make the backgrounds move Remove the server app. Improve the image generator. * Enable asset compression * Switch back to JavaScript Limit to 3 images on potentially metered connections.
1 parent 4f4c3f1 commit a67519a

39 files changed

+2064
-6451
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ jobs:
1010

1111
steps:
1212
- name: Install dependencies
13-
run: apk add gcc imagemagick-dev make musl-dev pkgconfig vips-dev
13+
run: apk add gcc imagemagick-dev make musl-dev pkgconfig
1414

1515
- name: Check out the repo
1616
uses: actions/checkout@v4
1717

1818
- name: Build
19-
run: make server img-out
20-
21-
- name: Build
22-
run: make image-resizer
19+
run: make imgen
2320

2421
- name: Run tests
2522
run: go test ./...
@@ -31,7 +28,7 @@ jobs:
3128

3229
steps:
3330
- name: Install dependencies
34-
run: apk add gcc imagemagick-dev musl-dev pkgconfig tar vips-dev
31+
run: apk add gcc imagemagick-dev musl-dev pkgconfig tar
3532

3633
- name: Check out the repo
3734
uses: actions/checkout@v4
@@ -43,23 +40,3 @@ jobs:
4340
uses: golangci/golangci-lint-action@v7
4441
with:
4542
install-mode: none
46-
47-
# test-js:
48-
# name: Build and test Javascript code
49-
# runs-on: ubuntu-latest
50-
#
51-
# steps:
52-
# - name: Check out code into the Go module directory
53-
# uses: actions/checkout@v2
54-
#
55-
# - uses: actions/setup-node@v2
56-
# with:
57-
# node-version: '17'
58-
# cache: 'npm'
59-
#
60-
# - run: npm install
61-
#
62-
# - run: npm test
63-
#
64-
# - name: Build the webapp
65-
# run: make webapp

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
.idea/
66

77
# built files
8-
image-resizer
9-
server
8+
imgen
109
dist/
11-
img-out
10+
backgrounds/
1211

1312
# Node stuff
1413
node_modules

Dockerfile

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ FROM golang:1.24.2-alpine as go-builder
22

33
WORKDIR /usr/src/app
44

5+
COPY backgrounds.mk .
56
COPY cmd/ cmd/
6-
COPY config/ config/
77
COPY img-src/ img-src/
8-
COPY internal/ internal/
9-
COPY Makefile Makefile
10-
COPY go.mod go.mod
11-
COPY go.sum go.sum
12-
COPY pkg/ pkg/
8+
COPY go.mod .
9+
COPY go.sum .
1310

14-
RUN ["apk", "add", "gcc", "git", "imagemagick-dev", "make", "musl-dev", "pkgconfig", "vips-dev"]
15-
RUN ["make", "server", "img-out"]
11+
RUN ["apk", "add", "gcc", "imagemagick-dev", "imagemagick-heic", "imagemagick-jpeg", "imagemagick-webp", "make", "musl-dev"]
12+
RUN ["make", "-f", "backgrounds.mk", "backgrounds/backgrounds.json"]
1613

1714
FROM python:3 as python-builder
1815

@@ -23,34 +20,23 @@ RUN ["make", "-C", "fa-src"]
2320

2421
FROM node:23-alpine as node-builder
2522

26-
RUN ["mkdir", "/build"]
23+
COPY --from=go-builder /usr/src/app /build
2724
WORKDIR /build
2825

29-
COPY config/ config/
30-
COPY fa-src/ fa-src/
26+
COPY fa-src fa-src
3127
COPY Makefile .
3228
COPY package.json .
3329
COPY package-lock.json .
34-
COPY tsconfig.json .
30+
COPY web-src web-src
3531
COPY webpack.config.js .
36-
COPY web-src/ web-src/
37-
38-
RUN ["mkdir", "dist"]
3932

4033
COPY --from=python-builder /fa-src/fa-brands.woff2 fa-src/
4134
COPY --from=python-builder /fa-src/fa-solid.woff2 fa-src/
4235

4336
RUN ["npm", "install", "."]
44-
4537
RUN ["apk", "add", "make"]
46-
RUN ["make", "webapp"]
47-
48-
FROM alpine
49-
50-
COPY --from=go-builder /usr/src/app/server /server
51-
COPY --from=go-builder /usr/src/app/img-out /img-out
52-
COPY --from=node-builder /build/dist /dist
38+
RUN ["make"]
5339

54-
EXPOSE 8080/tcp
40+
FROM scratch
5541

56-
ENTRYPOINT ["/server", "-img-out-dir", "img-out", "-webroot-dir", "dist"]
42+
COPY --from=node-builder /build/dist /

Makefile

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
all: img-out server webapp
1+
FONTS := $(addprefix web-src/webfonts/,fa-brands.woff2 fa-solid.woff2)
22

3-
image-resizer: $(shell find . -name '*.go' -type f) go.mod go.sum
4-
go build -o $@ $(GOTAGS) ./cmd/image-resizer
5-
6-
img-out: image-resizer $(wildcard img-src/*)
7-
mkdir -p $@
8-
./$< -img-out-dir $@ -img-in-dir img-src
3+
all: $(FONTS) backgrounds/backgrounds.json
4+
mkdir -p dist
5+
npx webpack --mode production
6+
cp -r backgrounds dist/backgrounds
97

10-
fontawesome-subsets:
8+
$(FONTS):
119
make -C fa-src
1210
mv fa-src/fa-brands.woff2 fa-src/fa-solid.woff2 web-src/webfonts/
1311

14-
webapp: fontawesome-subsets
15-
npx webpack --mode production
16-
17-
server: $(shell find . -name '*.go' -type f) go.mod go.sum
18-
go build -ldflags="-X main.version=$(shell cat VERSION)" -o $@ $(GOTAGS) ./cmd/server
19-
12+
.PHONY: clean
2013
clean:
21-
rm -fr img-out
22-
rm -f aot-images
23-
rm -f server
14+
rm -fr imgen img-out
15+
16+
include backgrounds.mk

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.0
1+
5.0.0

backgrounds.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
imgen: $(shell find . -name '*.go' -type f) go.mod go.sum
2+
go build -o $@ ./cmd/imgen
3+
4+
BACKGROUNDS_DIR := backgrounds
5+
6+
$(BACKGROUNDS_DIR)/backgrounds.json: imgen
7+
mkdir -p $(BACKGROUNDS_DIR)
8+
./$< -out-dir $(BACKGROUNDS_DIR) -in-dir img-src

0 commit comments

Comments
 (0)