diff --git a/Dockerfile b/Dockerfile index 8d38906..af6a693 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,30 +1,46 @@ +FROM golang:alpine AS deps + +WORKDIR /app +COPY go.mod go.sum ./ +RUN sed -i '/replace/d' go.mod +RUN go mod download + +#---------------------------------------------------------------------------------------------- + FROM golang:alpine AS builder WORKDIR /app -COPY . . - RUN apk add git -RUN go get github.com/beego/bee/v2 && go install github.com/beego/bee/v2@master +RUN go install github.com/beego/bee/v2@latest -RUN timeout 15 bee run -gendoc=true -downdoc=true -runmode=dev || : +WORKDIR /oc-workflow -RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' swagger/index.html +COPY --from=deps /go/pkg /go/pkg +COPY --from=deps /app/go.mod /app/go.sum ./ -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o setup . +RUN export CGO_ENABLED=0 && \ + export GOOS=linux && \ + export GOARCH=amd64 && \ + export BUILD_FLAGS="-ldflags='-w -s'" -RUN ls /app +COPY . . -FROM scratch +RUN sed -i '/replace/d' go.mod +RUN bee pack +RUN mkdir -p /app/extracted && tar -zxvf oc-workflow.tar.gz -C /app/extracted +RUN sed -i 's/http:\/\/127.0.0.1:8080\/swagger\/swagger.json/swagger.json/g' /app/extracted/swagger/index.html + +#---------------------------------------------------------------------------------------------- + +FROM golang:alpine WORKDIR /app - -COPY --from=builder /app/setup /usr/bin/ -COPY --from=builder /app/swagger /app/swagger - -COPY docker_conf.json /etc/oc/workflow.json +COPY --from=builder /app/extracted/oc-workflow /usr/bin/ +COPY --from=builder /app/extracted/swagger /app/swagger +COPY --from=builder /app/extracted/docker_conf.json /etc/oc/workflow.json EXPOSE 8080 -ENTRYPOINT ["setup"] +ENTRYPOINT ["oc-workflow"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..142e063 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +.DEFAULT_GOAL := all + +build: clean + bee pack + +run: + bee run -gendoc=true -downdoc=true + +debug: + bee run -downdebug -gendebug + +clean: + rm -rf oc-workflow.tar.gz + +docker: + DOCKER_BUILDKIT=1 docker build -t oc/oc-workflow:0.0.1 -f Dockerfile . + docker tag oc/oc-workflow:0.0.1 oc/oc-workflow:latest + +publish-kind: + kind load docker-image oc/oc-workflow:0.0.1 --name opencloud + +publish-registry: + @echo "TODO" + +all: clean docker publish-kind publish-registry + +.PHONY: build run clean docker publish-kind publish-registry \ No newline at end of file diff --git a/go.mod b/go.mod index 55184be..78297f3 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.0 toolchain go1.22.4 require ( - cloud.o-forge.io/core/oc-lib v0.0.0-20241121074503-15ca06aba883 + cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be github.com/beego/beego/v2 v2.3.1 github.com/nats-io/nats.go v1.37.0 github.com/smartystreets/goconvey v1.7.2 diff --git a/go.sum b/go.sum index 51ca44a..e5ff00e 100644 --- a/go.sum +++ b/go.sum @@ -1,39 +1,8 @@ -cloud.o-forge.io/core/oc-lib v0.0.0-20241106093658-06e048165e2a h1:TmCuwF62bktK4EeJ6z74FNbBMBT8O7f4lqQqsNbr+uw= -cloud.o-forge.io/core/oc-lib v0.0.0-20241106093658-06e048165e2a/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241107114600-4c0c75be9161 h1:so5V7C6kiJ9tpuxtgK/KcgjXQC2ythInAH8X2gohuaM= -cloud.o-forge.io/core/oc-lib v0.0.0-20241107114600-4c0c75be9161/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241107122526-f3df1e42b9ba h1:MGd8N7bY1LWXMhAp7gibDNwMS2hsatLQ3rfayvy5rGs= -cloud.o-forge.io/core/oc-lib v0.0.0-20241107122526-f3df1e42b9ba/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241108104423-7fd44a55cb28 h1:jekSPkD/b59kJ9Bp/trBWnahkdd1FkX4csQOcSaZa8I= -cloud.o-forge.io/core/oc-lib v0.0.0-20241108104423-7fd44a55cb28/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241112141026-06c3af5d4d61 h1:wAuOQAbv2uAie1QulHvbBzlZWMUE6hQ0kjhnP4OXFqQ= -cloud.o-forge.io/core/oc-lib v0.0.0-20241112141026-06c3af5d4d61/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241114090218-14fe694fd370 h1:3o0naAyt9oXs/dG4eygreVePBmjd516PEZrW9aviJ0Q= -cloud.o-forge.io/core/oc-lib v0.0.0-20241114090218-14fe694fd370/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241118144940-902ad0ea7144 h1:KC4lz5LzwXVz1M4eN9//sG45XqEwvMBY4NvrZw3vaE4= -cloud.o-forge.io/core/oc-lib v0.0.0-20241118144940-902ad0ea7144/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241119132823-94803f820af1 h1:c/gsB3C14u3f8PetaN24+lDfp/Bc1zL8UUj6kE0TWrQ= -cloud.o-forge.io/core/oc-lib v0.0.0-20241119132823-94803f820af1/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120085309-08e9ee67fe96 h1:1f2m8148/bOY19urpgtgShmGPDMnnjRqcEczrkVDJBA= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120085309-08e9ee67fe96/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120093920-b49685aa8223 h1:LX04VfuXWxi+Q0lKhBBd7tfyLO3R4y8um3srRVlMbSY= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120093920-b49685aa8223/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120150854-57f18b224443 h1:cqlL4/EsqYlQ6luPBC4+6+gWNwQqWVV8DPD8O7F6yM8= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120150854-57f18b224443/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120153807-3b77c0da8352 h1:xNYjEiB/nrvXLbLcjSDfNZEPSR38/LKcsQKP/oWg5HI= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120153807-3b77c0da8352/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120160521-ac49d3324d7b h1:5prB7K0iM284VmYdoRaBMZIOEXq5S0YgTrSp4+SnZyo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241120160521-ac49d3324d7b/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241121065159-d8fac883d260 h1:DSumHyw9XJQ/r+LjWa5GDkjS0ri/lFkU7oPr5vv8mws= -cloud.o-forge.io/core/oc-lib v0.0.0-20241121065159-d8fac883d260/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241121071546-e9b3a65a0ec6 h1:AdUkzaX63VF3fdloWyyWT1jLM4M1pkDLErAdHyVbsKU= -cloud.o-forge.io/core/oc-lib v0.0.0-20241121071546-e9b3a65a0ec6/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241121074503-15ca06aba883 h1:JdHJT8vuup4pJCC7rjiOe0/qD7at6400ml5zZHjEeUo= -cloud.o-forge.io/core/oc-lib v0.0.0-20241121074503-15ca06aba883/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= +cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be h1:1Yf8ihUxXjOEPqcfgtXJpJ/slxBUHhf7AgS7DZI3iUk= +cloud.o-forge.io/core/oc-lib v0.0.0-20250108155542-0f4adeea86be/go.mod h1:ya7Q+zHhaKM+XF6sAJ+avqHEVzaMnFJQih2X3TlTlGo= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/beego/beego/v2 v2.3.1 h1:7MUKMpJYzOXtCUsTEoXOxsDV/UcHw6CPbaWMlthVNsc= github.com/beego/beego/v2 v2.3.1/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4= -github.com/beego/beego/v2 v2.3.2/go.mod h1:5cqHsOHJIxkq44tBpRvtDe59GuVRVv/9/tyVDxd5ce4= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=