root: generate API Client in dockerfile instead of copying it (#942)

* root: generate API Client in dockerfile instead of copying it

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* outpost: fix docker build

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* root: fix path for docker build

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>

* outpost: set explicit buildContext

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens L 2021-05-30 17:28:58 +02:00 committed by GitHub
parent 80adafdb48
commit 6a9c95c593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 49 deletions

View File

@ -28,9 +28,6 @@ jobs:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: prepare ts api client
run: |
make gen-web
- name: Building Docker Image
uses: docker/build-push-action@v2
with:
@ -49,11 +46,6 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: "^1.15"
- name: prepare go api client
run: |
make gen-outpost
cd outpost
go build -v ./cmd/proxy/server.go
- name: Set up QEMU
uses: docker/setup-qemu-action@v1.2.0
- name: Set up Docker Buildx
@ -78,7 +70,6 @@ jobs:
beryju/authentik-proxy:latest,
ghcr.io/goauthentik/proxy:2021.5.4,
ghcr.io/goauthentik/proxy:latest
context: outpost/
file: outpost/proxy.Dockerfile
platforms: linux/amd64,linux/arm64
build-ldap:
@ -88,11 +79,6 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: "^1.15"
- name: prepare go api client
run: |
make gen-outpost
cd outpost
go build -v ./cmd/ldap/server.go
- name: Set up QEMU
uses: docker/setup-qemu-action@v1.2.0
- name: Set up Docker Buildx
@ -117,7 +103,6 @@ jobs:
beryju/authentik-ldap:latest,
ghcr.io/goauthentik/ldap:2021.5.4,
ghcr.io/goauthentik/ldap:latest
context: outpost/
file: outpost/ldap.Dockerfile
platforms: linux/amd64,linux/arm64
test-release:

View File

@ -11,9 +11,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: prepare ts api client
run: |
make gen-web
- name: Pre-release test
run: |
sudo apt-get install -y pwgen

View File

@ -10,15 +10,27 @@ RUN pip install pipenv && \
pipenv lock -r > requirements.txt && \
pipenv lock -rd > requirements-dev.txt
# Stage 2: Build webui
# Stage 2: Build web API
FROM openapitools/openapi-generator-cli as api-builder
COPY ./schema.yml /local/schema.yml
RUN docker-entrypoint.sh generate \
-i /local/schema.yml \
-g typescript-fetch \
-o /local/web/api \
--additional-properties=typescriptThreePlus=true,supportsES6=true,npmName=authentik-api,npmVersion=1.0.0
# Stage 3: Build webui
FROM node as npm-builder
COPY ./web /static/
COPY --from=api-builder /local/web/api /static/api
ENV NODE_ENV=production
RUN cd /static && npm i --production=false && npm run build
# Stage 3: Build go proxy
# Stage 4: Build go proxy
FROM golang:1.16.4 AS builder
WORKDIR /work
@ -28,7 +40,6 @@ COPY --from=npm-builder /static/security.txt /work/web/security.txt
COPY --from=npm-builder /static/dist/ /work/web/dist/
COPY --from=npm-builder /static/authentik/ /work/web/authentik/
# RUN ls /work/web/static/authentik/ && exit 1
COPY ./cmd /work/cmd
COPY ./web/static.go /work/web/static.go
COPY ./internal /work/internal
@ -37,7 +48,7 @@ COPY ./go.sum /work/go.sum
RUN go build -o /work/authentik ./cmd/server/main.go
# Stage 4: Run
# Stage 5: Run
FROM python:3.9-slim-buster
WORKDIR /

View File

@ -399,13 +399,6 @@ stages:
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
- task: CmdLine@2
inputs:
script: make gen-web
- task: Bash@3
inputs:
targetType: 'inline'

View File

@ -99,11 +99,6 @@ stages:
- task: GoTool@0
inputs:
version: '1.16.3'
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'go_api_client'
path: "outpost/api/"
- task: Bash@3
inputs:
targetType: 'inline'
@ -115,7 +110,7 @@ stages:
repository: 'authentik/outpost-proxy'
command: 'build'
Dockerfile: 'outpost/proxy.Dockerfile'
buildContext: 'outpost/'
buildContext: '$(Build.SourcesDirectory)'
tags: |
gh-$(branchName)
gh-$(Build.SourceVersion)
@ -135,11 +130,6 @@ stages:
- task: GoTool@0
inputs:
version: '1.16.3'
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'go_api_client'
path: "outpost/api/"
- task: Bash@3
inputs:
targetType: 'inline'
@ -151,7 +141,7 @@ stages:
repository: 'authentik/outpost-ldap'
command: 'build'
Dockerfile: 'outpost/ldap.Dockerfile'
buildContext: 'outpost/'
buildContext: '$(Build.SourcesDirectory)'
tags: |
gh-$(branchName)
gh-$(Build.SourceVersion)

View File

@ -1,15 +1,33 @@
# Stage 1: Generate API Client
FROM openapitools/openapi-generator-cli as api-builder
COPY ./schema.yml /local/schema.yml
RUN docker-entrypoint.sh generate \
--git-host goauthentik.io \
--git-repo-id outpost \
--git-user-id api \
-i /local/schema.yml \
-g go \
-o /local/outpost/api \
--additional-properties=packageName=api,enumClassPrefix=true,useOneOfDiscriminatorLookup=true && \
rm -f /local/outpost/api/go.mod /local/outpost/api/go.sum
# Stage 2: Build
FROM golang:1.16.4 AS builder
ARG GIT_BUILD_HASH
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
WORKDIR /work
WORKDIR /go/src/goauthentik.io/outpost
COPY . .
COPY ./outpost .
COPY --from=api-builder /local/outpost/api api
RUN go build -o /work/ldap ./cmd/ldap
RUN go build -o /go/ldap ./cmd/ldap
# Stage 3: Run
FROM gcr.io/distroless/base-debian10:debug
COPY --from=builder /work/ldap /
COPY --from=builder /go/ldap /
ENTRYPOINT ["/ldap"]

View File

@ -1,16 +1,34 @@
# Stage 1: Generate API Client
FROM openapitools/openapi-generator-cli as api-builder
COPY ./schema.yml /local/schema.yml
RUN docker-entrypoint.sh generate \
--git-host goauthentik.io \
--git-repo-id outpost \
--git-user-id api \
-i /local/schema.yml \
-g go \
-o /local/outpost/api \
--additional-properties=packageName=api,enumClassPrefix=true,useOneOfDiscriminatorLookup=true && \
rm -f /local/outpost/api/go.mod /local/outpost/api/go.sum
# Stage 2: Build
FROM golang:1.16.4 AS builder
ARG GIT_BUILD_HASH
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
WORKDIR /work
WORKDIR /go/src/goauthentik.io/outpost
COPY . .
COPY ./outpost .
COPY --from=api-builder /local/outpost/api api
RUN go build -o /work/proxy ./cmd/proxy
RUN go build -o /go/proxy ./cmd/proxy
# Stage 3: Run
FROM gcr.io/distroless/base-debian10:debug
COPY --from=builder /work/proxy /
COPY --from=builder /go/proxy /
HEALTHCHECK CMD [ "wget", "--spider", "http://localhost:4180/akprox/ping" ]