#109 update deployment
All checks were successful
Build Docker Image / Explore-Gitea-Actions (push) Successful in 47s

This commit is contained in:
Tim
2024-08-24 19:33:22 +02:00
parent 1db7893db5
commit 936e6bc1c6
9 changed files with 41 additions and 43 deletions

View File

@@ -11,7 +11,6 @@ tmp_dir = "tmp"
exclude_regex = ["_test.go", "_templ.go"] exclude_regex = ["_test.go", "_templ.go"]
exclude_unchanged = false exclude_unchanged = false
follow_symlink = false follow_symlink = false
full_bin = ""
include_dir = [] include_dir = []
include_ext = ["go", "templ", "html"] include_ext = ["go", "templ", "html"]
include_file = [] include_file = []

View File

@@ -11,11 +11,5 @@ jobs:
steps: steps:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- run: docker build api/ -t api-test - run: docker build . -t me-fit-test
- run: docker rmi api-test - run: docker rmi me-fit-test
- run: |
docker build \
--build-arg="PUBLIC_BASE_API_URL=${{ vars.PUBLIC_BASE_API_URL }}" \
-t view-test \
view/
- run: docker rmi view-test

View File

@@ -11,20 +11,10 @@ jobs:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- run: docker login git.wundenbergs.de -u tim -p ${{ secrets.DOCKER_GITEA_TOKEN }} - run: docker login git.wundenbergs.de -u tim -p ${{ secrets.DOCKER_GITEA_TOKEN }}
- run: | - run: docker build . \
docker build \ -t git.wundenbergs.de/tim/me-fit:latest \
-t git.wundenbergs.de/tim/me-fit/api:latest \ -t git.wundenbergs.de/tim/me-fit:$GITHUB_SHA \
-t git.wundenbergs.de/tim/me-fit/api:$GITHUB_SHA \ - run: docker push git.wundenbergs.de/tim/me-fit:latest
api/ - run: docker push git.wundenbergs.de/tim/me-fit:$GITHUB_SHA
- run: docker push git.wundenbergs.de/tim/me-fit/api:latest - run: docker rmi git.wundenbergs.de/tim/me-fit:latest git.wundenbergs.de/tim/me-fit:$GITHUB_SHA
- run: docker push git.wundenbergs.de/tim/me-fit/api:$GITHUB_SHA
- run: docker rmi git.wundenbergs.de/tim/me-fit/api:latest git.wundenbergs.de/tim/me-fit/api:$GITHUB_SHA
- run: |
docker build \
--build-arg="PUBLIC_BASE_API_URL=${{ vars.PUBLIC_BASE_API_URL }}" \
-t git.wundenbergs.de/tim/me-fit/view:latest \
-t git.wundenbergs.de/tim/me-fit/view:$GITHUB_SHA \
view/
- run: docker push git.wundenbergs.de/tim/me-fit/view:latest
- run: docker push git.wundenbergs.de/tim/me-fit/view:$GITHUB_SHA
- run: docker rmi git.wundenbergs.de/tim/me-fit/view:latest git.wundenbergs.de/tim/me-fit/view:$GITHUB_SHA

1
.gitignore vendored
View File

@@ -30,4 +30,5 @@ secrets/
node_modules/ node_modules/
static/css/tailwind.css static/css/tailwind.css
static/js/htmx.min.js
tmp/ tmp/

View File

@@ -1,17 +1,22 @@
FROM golang:1.23@sha256:613a108a4a4b1dfb6923305db791a19d088f77632317cfc3446825c54fb862cd AS builder FROM golang:1.23.0 AS BUILDER_GO
WORKDIR /me-fit
WORKDIR /app RUN go install github.com/a-h/templ/cmd/templ@latest
COPY go.mod go.sum main.go ./ COPY . ./
COPY src src RUN templ generate && go build -o /me-fit/me-fit .
RUN go build -o /bin/api ./main.go
FROM debian:stable-slim@sha256:382967fd7c35a0899ca3146b0b73d0791478fba2f71020c7aa8c27e3a4f26672 FROM node:22.7.0 AS BUILDER_NODE
WORKDIR /me-fit
COPY . ./
RUN npm install && npm run build
RUN apt-get update && apt-get install -y ca-certificates
WORKDIR /app FROM debian:12.6
COPY --from=builder /bin/api ./api WORKDIR /me-fit
RUN apt-get update && apt-get install -y ca-certificates && echo "" > .env
COPY --from=BUILDER_GO /me-fit/me-fit ./me-fit
COPY --from=BUILDER_NODE /me-fit/static ./static
COPY migrations ./migrations COPY migrations ./migrations
EXPOSE 8080 EXPOSE 8080
ENTRYPOINT ["/app/api"] ENTRYPOINT ["/me-fit/me-fit"]

9
package-lock.json generated
View File

@@ -9,7 +9,8 @@
"version": "1.0.0", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"daisyui": "^4.12.10", "daisyui": "4.12.10",
"htmx.org": "2.0.2",
"tailwindcss": "3.4.10" "tailwindcss": "3.4.10"
} }
}, },
@@ -525,6 +526,12 @@
"node": ">= 0.4" "node": ">= 0.4"
} }
}, },
"node_modules/htmx.org": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/htmx.org/-/htmx.org-2.0.2.tgz",
"integrity": "sha512-eUPIpQaWKKstX393XNCRCMJTrqPzikh36Y9RceqsUZLTtlFjFaVDgwZLUsrFk8J2uzZxkkfiy0TE359j2eN6hA==",
"dev": true
},
"node_modules/is-binary-path": { "node_modules/is-binary-path": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",

View File

@@ -4,14 +4,16 @@
"description": "Your (almost) independent tech stack to host on a VPC.", "description": "Your (almost) independent tech stack to host on a VPC.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "tailwindcss build -o static/css/tailwind.css --minify", "build": "mkdir -p static/js && cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss build -o static/css/tailwind.css --minify",
"watch": "tailwindcss build -o static/css/tailwind.css --watch" "watch": "mkdir -p static/js && cp -f node_modules/htmx.org/dist/htmx.min.js static/js/htmx.min.js && tailwindcss build -o static/css/tailwind.css --watch",
"test": ""
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"daisyui": "^4.12.10", "htmx.org": "2.0.2",
"tailwindcss": "3.4.10" "tailwindcss": "3.4.10",
"daisyui": "4.12.10"
} }
} }

View File

@@ -11,6 +11,7 @@ func HandleIndexAnd404(w http.ResponseWriter, r *http.Request) {
var comp templ.Component = nil var comp templ.Component = nil
if r.URL.Path != "/" { if r.URL.Path != "/" {
comp = templates.Layout(templates.NotFound()) comp = templates.Layout(templates.NotFound())
w.WriteHeader(http.StatusNotFound)
} else { } else {
comp = templates.Layout(templates.Index()) comp = templates.Layout(templates.Index())
} }

View File

@@ -27,7 +27,6 @@ func App(w http.ResponseWriter, r *http.Request) {
comp := templates.App() comp := templates.App()
layout := templates.Layout(comp) layout := templates.Layout(comp)
layout.Render(r.Context(), w) layout.Render(r.Context(), w)
w.WriteHeader(http.StatusOK)
} }
func NewWorkout(db *sql.DB) http.HandlerFunc { func NewWorkout(db *sql.DB) http.HandlerFunc {