Add template support.

This commit is contained in:
2024-08-26 23:12:33 +02:00
parent 30f8be3d5d
commit e87dfaf38b
11 changed files with 707 additions and 381 deletions

22
templates/Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM alpine
RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata
# Set timezone if necessary
#ENV TZ UTC
ENV USER=gouser
ENV UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
"${USER}"
ADD {{.ProjectFolderName}} /app/{{.ProjectFolderName}}
WORKDIR /app
USER gouser:gouser
ENTRYPOINT ["./{{.ProjectFolderName}}"]

18
templates/docker_image.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
mkdir -p _build
cd _build
mkdir -p docker_out
rm -rf sources
git clone $(git remote get-url origin) sources
cd sources
git fetch --tags
ver=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $ver
CGO_ENABLED=0 go build -ldflags="-s -w" -o ../{{.ProjectFolderName}} .
# A second run is needed to build the final image.
cd ..
docker build -f sources/Dockerfile --no-cache -t {{.GoModuleName}}:${ver} .
docker push {{.GoModuleName}}:${ver}
rm -rf sources {{.ProjectFolderName}}

View File

@ -0,0 +1,34 @@
- esbuild:
entryPoints:
- frontend/the-app.js
outdir: ./frontend-dist
sourcemap: 1
format: 3
splitting: true
platform: 0
bundle: true
write: true
logLevel: 3
purgeBeforeBuild: false
watch:
paths:
- ./frontend/src
exclude: []
# serve: # Uncomment and set a path to enable
# path: ""
# port: 8080
copy:
- src: ./frontend/index.html
dest: ./frontend-dist
# download:
# - url: https://example.com/some-file-or-asset.js
# dest: ./frontend/src/vendor/some-file-or-asset.js
# replace:
# - pattern: "*.go|*.js|*.html"
# search: "Something"
# replace: "This"
# link:
# from: ../../web/tp-elements
# to: ./frontend
# productionBuildOptions:
# cmdPostBuild: ""