diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index a219162d19..0000000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,79 +0,0 @@ -name: Build Binaries - -on: - pull_request: - branches: - - '*' - -env: - GO_VERSION: '1.20' - CGO_ENABLED: 0 - IN_DOCKER: "" - -jobs: - - build-webui: - runs-on: ubuntu-20.04 - - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Build webui - run: | - make clean-webui generate-webui - tar czvf webui.tar.gz ./webui/static/ - - - name: Artifact webui - uses: actions/upload-artifact@v2 - with: - name: webui.tar.gz - path: webui.tar.gz - - build: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-20.04, macos-latest, windows-latest ] - needs: - - build-webui - defaults: - run: - working-directory: ${{ github.workspace }}/go/src/github.com/traefik/traefik - - steps: - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Check out code - uses: actions/checkout@v2 - with: - path: go/src/github.com/traefik/traefik - fetch-depth: 0 - - - name: Cache Go modules - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - ~/Library/Caches/go-build - '%LocalAppData%\go-build' - key: ${{ runner.os }}-build-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-build-go- - - - name: Artifact webui - uses: actions/download-artifact@v2 - with: - name: webui.tar.gz - path: ${{ github.workspace }}/go/src/github.com/traefik/traefik - - - name: Untar webui - run: tar xvf webui.tar.gz - - - name: Build - run: make binary diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml new file mode 100644 index 0000000000..aff47e9143 --- /dev/null +++ b/.github/workflows/build_and_push.yml @@ -0,0 +1,41 @@ +name: On Pull Request + +on: + pull_request: + branches: [patched] + +jobs: + test: + name: build_and_push + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Docker Layer Cache + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-docker-${{ github.event.number }} + restore-keys: ${{ runner.os }}-docker- + + # Buildx Needs QEMU + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + # We use Buildx so we can take advantage of the caching + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + tags: ghcr.io/${{ github.repository }}:PR${{ github.event.number }} + push: true diff --git a/.github/workflows/check_doc.yml b/.github/workflows/check_doc.yml deleted file mode 100644 index c800ad248e..0000000000 --- a/.github/workflows/check_doc.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Check Documentation - -on: - pull_request: - branches: - - '*' - -jobs: - - docs: - name: Check, verify and build documentation - runs-on: ubuntu-20.04 - - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Check documentation - run: make docs-pull-images docs - env: - # These variables are not passed to workflows that are triggered by a pull request from a fork. - DOCS_VERIFY_SKIP: ${{ vars.DOCS_VERIFY_SKIP }} - DOCS_LINT_SKIP: ${{ vars.DOCS_LINT_SKIP }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 3425536afe..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: - - master - - v* - schedule: - - cron: '11 22 * * 1' - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'javascript', 'go' ] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Use only 'java' to analyze code written in Java, Kotlin or both - # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both - # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - - # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # ℹī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. - - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml deleted file mode 100644 index f9cc865193..0000000000 --- a/.github/workflows/documentation.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build and Publish Documentation - -on: - push: - branches: - - master - - v* - -env: - STRUCTOR_VERSION: v1.13.2 - MIXTUS_VERSION: v0.4.1 - -jobs: - - docs: - name: Doc Process - runs-on: ubuntu-20.04 - if: github.repository == 'traefik/traefik' - - steps: - - name: Check out code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Install Structor ${{ env.STRUCTOR_VERSION }} - run: curl -sSfL https://raw.githubusercontent.com/traefik/structor/master/godownloader.sh | sh -s -- -b $HOME/bin ${STRUCTOR_VERSION} - - - name: Install Seo-doc - run: curl -sSfL https://raw.githubusercontent.com/traefik/seo-doc/master/godownloader.sh | sh -s -- -b "${HOME}/bin" - - - name: Install Mixtus ${{ env.MIXTUS_VERSION }} - run: curl -sSfL https://raw.githubusercontent.com/traefik/mixtus/master/godownloader.sh | sh -s -- -b $HOME/bin ${MIXTUS_VERSION} - - - name: Build documentation - run: $HOME/bin/structor -o traefik -r traefik --dockerfile-url="https://raw.githubusercontent.com/traefik/traefik/v1.7/docs.Dockerfile" --menu.js-url="https://raw.githubusercontent.com/traefik/structor/master/traefik-menu.js.gotmpl" --rqts-url="https://raw.githubusercontent.com/traefik/structor/master/requirements-override.txt" --force-edit-url --exp-branch=master --debug - env: - STRUCTOR_LATEST_TAG: ${{ vars.STRUCTOR_LATEST_TAG }} - - - name: Apply seo - run: $HOME/bin/seo -path=./site -product=traefik - - - name: Publish documentation - run: $HOME/bin/mixtus --dst-doc-path="./traefik" --dst-owner=traefik --dst-repo-name=doc --git-user-email="30906710+traefiker@users.noreply.github.com" --git-user-name=traefiker --src-doc-path="./site" --src-owner=containous --src-repo-name=traefik - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }} diff --git a/.github/workflows/experimental.yaml b/.github/workflows/experimental.yaml deleted file mode 100644 index 2b002a484d..0000000000 --- a/.github/workflows/experimental.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: Build experimental image on branch - -on: - push: - branches: - - master - - v* - -jobs: - - experimental: - if: github.repository == 'traefik/traefik' - name: Build experimental image on branch - runs-on: ubuntu-20.04 - - steps: - - # https://github.com/marketplace/actions/checkout - - name: Check out code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Branch name - run: echo ${GITHUB_REF##*/} - - - name: Build docker experimental image - run: docker build -t traefik/traefik:experimental-${GITHUB_REF##*/} -f exp.Dockerfile . - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push to Docker Hub - run: docker push traefik/traefik:experimental-${GITHUB_REF##*/} diff --git a/.github/workflows/test-unit.yaml b/.github/workflows/test-unit.yaml deleted file mode 100644 index ad9edcf414..0000000000 --- a/.github/workflows/test-unit.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: Test Unit - -on: - pull_request: - branches: - - '*' - -env: - GO_VERSION: '1.20' - IN_DOCKER: "" - -jobs: - - test-unit: - runs-on: ubuntu-20.04 - - defaults: - run: - working-directory: ${{ github.workspace }}/go/src/github.com/traefik/traefik - - steps: - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Check out code - uses: actions/checkout@v2 - with: - path: go/src/github.com/traefik/traefik - fetch-depth: 0 - - - name: Cache Go modules - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-test-unit-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-test-unit-go- - - - name: Avoid generating webui - run: touch webui/static/index.html - - - name: Tests - run: make test-unit diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml deleted file mode 100644 index e40e51dbb8..0000000000 --- a/.github/workflows/validate.yaml +++ /dev/null @@ -1,97 +0,0 @@ -name: Validate - -on: - pull_request: - branches: - - '*' - -env: - GO_VERSION: '1.20' - GOLANGCI_LINT_VERSION: v1.53.1 - MISSSPELL_VERSION: v0.4.0 - IN_DOCKER: "" - -jobs: - - validate: - runs-on: ubuntu-20.04 - - defaults: - run: - working-directory: ${{ github.workspace }}/go/src/github.com/traefik/traefik - - steps: - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Check out code - uses: actions/checkout@v2 - with: - path: go/src/github.com/traefik/traefik - fetch-depth: 0 - - - name: Cache Go modules - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-validate-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-validate-go- - - - name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} - run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} - - - name: Install missspell ${{ env.MISSSPELL_VERSION }} - run: curl -sfL https://raw.githubusercontent.com/golangci/misspell/master/install-misspell.sh | sh -s -- -b $(go env GOPATH)/bin ${MISSSPELL_VERSION} - - - name: Avoid generating webui - run: touch webui/static/index.html - - - name: Validate - run: make validate - - validate-generate: - runs-on: ubuntu-20.04 - - defaults: - run: - working-directory: ${{ github.workspace }}/go/src/github.com/traefik/traefik - - steps: - - name: Set up Go ${{ env.GO_VERSION }} - uses: actions/setup-go@v2 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Check out code - uses: actions/checkout@v2 - with: - path: go/src/github.com/traefik/traefik - fetch-depth: 0 - - - name: Cache Go modules - uses: actions/cache@v3 - with: - path: | - ~/go/pkg/mod - ~/.cache/go-build - key: ${{ runner.os }}-validate-generate-go-${{ hashFiles('**/go.sum') }} - restore-keys: ${{ runner.os }}-validate-generate-go- - - - name: go generate - run: | - go generate - git diff --exit-code - - - name: go mod tidy - run: | - go mod tidy - git diff --exit-code - - - name: make generate-crd - run: | - make generate-crd - git diff --exit-code diff --git a/Dockerfile b/Dockerfile index 873d55312d..e2de975852 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,48 @@ -FROM scratch -COPY script/ca-certificates.crt /etc/ssl/certs/ -COPY dist/traefik / +# WEBUI +FROM node:12.11 as webui + +ENV WEBUI_DIR /src/webui +RUN mkdir -p $WEBUI_DIR + +COPY ./webui/ $WEBUI_DIR/ + +WORKDIR $WEBUI_DIR + +RUN yarn install +RUN yarn build + +# BUILD +FROM golang:1.20-alpine as gobuild + +RUN apk --no-cache --no-progress add git mercurial bash gcc musl-dev curl tar ca-certificates tzdata \ + && update-ca-certificates \ + && rm -rf /var/cache/apk/* + +WORKDIR /go/src/github.com/mailgun/traefik + +# Download go modules +COPY go.mod . +COPY go.sum . +RUN GO111MODULE=on GOPROXY=https://proxy.golang.org go mod download + +COPY . /go/src/github.com/mailgun/traefik + +RUN rm -rf /go/src/github.com/mailgun/traefik/webui/static/ +COPY --from=webui /src/webui/static/ /go/src/github.com/mailgun/traefik/webui/static/ + +RUN go generate +RUN CGO_ENABLED=0 GOGC=off go build -ldflags "-s -w" -o dist/traefik ./cmd/traefik + +## IMAGE +FROM alpine:3.14 + +RUN apk --no-cache --no-progress add bash curl ca-certificates tzdata \ + && update-ca-certificates \ + && rm -rf /var/cache/apk/* + +COPY --from=gobuild /go/src/github.com/mailgun/traefik/dist/traefik / + EXPOSE 80 VOLUME ["/tmp"] + ENTRYPOINT ["/traefik"]