Skip to content

Commit

Permalink
🐛 fix volumes in shared containers, update demo output for new rulese…
Browse files Browse the repository at this point in the history
…ts (#205)

* 🐛 fix volumes in shared containers, update demo output for new rulesets, switch     back to using latest rulesets

Signed-off-by: Pranav Gaikwad <[email protected]>

* Upgrade podman in the runner

Signed-off-by: Pranav Gaikwad <[email protected]>

---------

Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad authored Apr 25, 2024
1 parent a3de93b commit 087909a
Show file tree
Hide file tree
Showing 7 changed files with 587 additions and 231 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/multi-arch-image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ jobs:
image_name: "kantra"
containerfile: "./Dockerfile"
architectures: '[ "amd64", "arm64" ]'
pre_build_cmd: |
TAG=${GITHUB_REF_NAME/main/latest}
sed -i "s,FROM quay.io/konveyor/windup-shim\:latest,FROM quay.io/konveyor/windup-shim:${TAG}," Dockerfile
sed -i "s,FROM quay.io/konveyor/static-report\:latest,FROM quay.io/konveyor/static-report:${TAG}," Dockerfile
sed -i "s,FROM quay.io/konveyor/analyzer-lsp\:latest,FROM quay.io/konveyor/analyzer-lsp:${TAG}," Dockerfile
extra-args: |
--build-arg VERSION=${{ github.ref == 'refs/heads/main' && 'latest' || github.ref_name }} --build-arg BUILD_COMMIT=${{ github.sha }}
--build-arg RULESETS_REF=${{ github.ref_name }} --build-arg VERSION=${{ github.ref_name == 'main' && 'latest' || github.ref_name }} --build-arg BUILD_COMMIT=${{ github.sha }}
secrets:
registry_username: ${{ secrets.QUAY_PUBLISH_ROBOT }}
registry_password: ${{ secrets.QUAY_PUBLISH_TOKEN }}
11 changes: 11 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Upgrade podman
run: |
sudo apt-get install -y ansible
export DEB=$(curl -s https://passt.top/builds/latest/x86_64/ | grep deb | awk -F '"' '{ print $4}')
sudo ansible -m apt -a deb=https://passt.top/builds/latest/x86_64/${DEB} localhost
sudo apt-get remove podman crun
brew install crun podman
- name: Extract pull request number from inputs or PR description
run: |
echo "${{ github.event.pull_request.body }}"
Expand Down
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
FROM quay.io/konveyor/windup-shim:latest as shim
ARG VERSION=latest
FROM quay.io/konveyor/windup-shim:${VERSION} as shim

FROM registry.access.redhat.com/ubi9-minimal as rulesets

ARG RULESETS_REF=main
RUN microdnf -y install git &&\
git clone --branch v0.4.0-alpha.1 https://github.com/konveyor/rulesets &&\
git clone https://github.com/konveyor/rulesets -b ${RULESETS_REF} &&\
git clone https://github.com/windup/windup-rulesets -b 6.3.1.Final

FROM quay.io/konveyor/static-report:latest as static-report
FROM quay.io/konveyor/static-report:${VERSION} as static-report

# Build the manager binary
FROM golang:1.21 as builder
Expand All @@ -25,15 +27,15 @@ COPY cmd/ cmd/
COPY pkg/ pkg/

# Build
ARG VERSION
ARG VERSION=latest
ARG BUILD_COMMIT
RUN CGO_ENABLED=0 GOOS=linux go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o kantra main.go
RUN CGO_ENABLED=0 GOOS=darwin go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o darwin-kantra main.go
RUN CGO_ENABLED=0 GOOS=windows go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=$VERSION' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$BUILD_COMMIT'" -a -o windows-kantra main.go

FROM quay.io/konveyor/analyzer-lsp:latest
FROM quay.io/konveyor/analyzer-lsp:${VERSION}

RUN mkdir /opt/rulesets /opt/rulesets/input /opt/rulesets/convert /opt/openrewrite /opt/input /opt/input/rules /opt/input/rules/custom /opt/output /opt/xmlrules /opt/shimoutput /tmp/source-app /tmp/source-app/input
RUN mkdir -p /opt/rulesets /opt/rulesets/input /opt/rulesets/convert /opt/openrewrite /opt/input /opt/input/rules /opt/input/rules/custom /opt/output /opt/xmlrules /opt/shimoutput /tmp/source-app /tmp/source-app/input

COPY --from=builder /workspace/kantra /usr/local/bin/kantra
COPY --from=builder /workspace/darwin-kantra /usr/local/bin/darwin-kantra
Expand Down
8 changes: 3 additions & 5 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,11 +751,9 @@ func (a *analyzeCommand) createContainerVolume(sourceInput string) (string, erro
"volume",
"create",
"--opt",
"type=none",
"type=bind",
"--opt",
fmt.Sprintf("device=%v", sourceInput),
"--opt",
"o=bind",
volName,
}

Expand Down Expand Up @@ -793,7 +791,7 @@ func (a *analyzeCommand) RunProviders(ctx context.Context, networkName string, v
}
volumes := map[string]string{
// application source code
a.input: SourceMountPath,
volName: SourceMountPath,
}
// this will make more sense when we have more than 2 supported providers
var providerImage string
Expand Down Expand Up @@ -836,7 +834,7 @@ func (a *analyzeCommand) RunProviders(ctx context.Context, networkName string, v
func (a *analyzeCommand) RunAnalysis(ctx context.Context, xmlOutputDir string, volName string, providers []string, ports map[string]int) error {
volumes := map[string]string{
// application source code
a.input: SourceMountPath,
volName: SourceMountPath,
// output directory
a.output: OutputPath,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (c *container) Run(ctx context.Context, opts ...Option) error {
for sourcePath, destPath := range c.volumes {
args = append(args, "-v")
if os == "linux" {
args = append(args, fmt.Sprintf("%s:%s:Z",
args = append(args, fmt.Sprintf("%s:%s:z",
filepath.Clean(sourcePath), path.Clean(destPath)))
} else {
args = append(args, fmt.Sprintf("%s:%s",
Expand Down
Loading

0 comments on commit 087909a

Please sign in to comment.