-
Notifications
You must be signed in to change notification settings - Fork 126
MCO-280: extensions: Add container to serve repository with extensions #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash | ||
| # TODO: share this with ci/prow-entrypoint.sh | ||
| ocpver=$(rpm-ostree compose tree --print-only manifest.yaml | jq -r '.["mutate-os-release"]') | ||
| ocpver_mut=$(rpm-ostree compose tree --print-only manifest.yaml | jq -r '.["mutate-os-release"]' | sed 's|\.|-|') | ||
| rhelver=$(rpm-ostree compose tree --print-only manifest.yaml | jq -r '.["automatic-version-prefix"]' | cut -f2 -d.) | ||
|
|
||
| curl -L "http://base-${ocpver_mut}-rhel${rhelver}.ocp.svc.cluster.local" -o "ocp.repo" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| ARG RHCOS_VERSION=latest | ||
jmarrero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #Build a newer rpm-ostree | ||
| FROM quay.io/centos/centos:stream8 as rpm-ostree | ||
| RUN sed -i -e 's,enabled=0,enabled=1,' /etc/yum.repos.d/CentOS-Stream-PowerTools.repo | ||
| RUN yum -y group install "Development Tools" | ||
|
|
||
| RUN git clone https://github.com/coreos/rpm-ostree.git | ||
| WORKDIR rpm-ostree | ||
| RUN git checkout rhel8 | ||
| RUN ./ci/installdeps.sh | ||
| RUN PATH=$PATH:/rpm-ostree/target/cxxbridge/bin/ | ||
| RUN git submodule update --init | ||
| RUN env CFLAGS='-ggdb -Og' CXXFLAGS='-ggdb -Og' ./autogen.sh --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc | ||
| RUN make | ||
|
|
||
| ## Downloads the extensions given the extensions.yaml | ||
| FROM registry.ci.openshift.org/rhcos-devel/rhel-coreos:${RHCOS_VERSION} as os | ||
|
|
||
| # Install new rpm-ostree | ||
| COPY --from=rpm-ostree /rpm-ostree/target/debug/rpm-ostree /usr/bin/rpm-ostree | ||
|
|
||
| # Expects os to be cloned and this build run from the top level dir like: | ||
| # podman build -f extensions/Dockerfile . | ||
| # also expects submodules to be initialized | ||
| RUN mkdir /os | ||
| WORKDIR /os | ||
| ADD . . | ||
| RUN if [ ! -f ocp.repo ]; then ci/get-ocp-repo.sh ; fi | ||
|
|
||
| RUN rpm-ostree compose extensions --rootfs=/ --output-dir=/usr/share/rpm-ostree/extensions/ {manifest,extensions}.yaml | ||
|
|
||
| ## Creates the repo metadata for the extensions & builds the go binary | ||
| FROM quay.io/centos/centos:stream8 as builder | ||
| COPY --from=os /usr/share/rpm-ostree/extensions/ /usr/share/rpm-ostree/extensions/ | ||
| RUN dnf install -y createrepo_c golang | ||
cgwalters marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ADD extensions/repo-server/main.go . | ||
| RUN mkdir /build | ||
| RUN go build -o /build/webserver main.go | ||
|
|
||
jmarrero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| RUN createrepo_c /usr/share/rpm-ostree/extensions/ | ||
|
|
||
| ## Final container that has the extensions and webserver | ||
| FROM registry.access.redhat.com/ubi8/ubi:latest | ||
| COPY --from=builder /build/webserver /usr/bin/webserver | ||
| COPY --from=builder /usr/share/rpm-ostree/extensions/ /usr/share/rpm-ostree/extensions/ | ||
|
|
||
| CMD ["./usr/bin/webserver"] | ||
| EXPOSE 9091/tcp | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "log" | ||
| "net/http" | ||
| ) | ||
|
|
||
| var ( | ||
| // flagPort is the open port the application listens on | ||
| flagPort = flag.String("port", "9091", "Port to listen on") | ||
| ) | ||
|
|
||
| func main() { | ||
| extensions := http.FileServer(http.Dir("/usr/share/rpm-ostree/extensions/")) | ||
| flag.Parse() | ||
| mux := http.NewServeMux() | ||
| mux.Handle("/", extensions) | ||
|
|
||
| log.Printf("listening on port %s", *flagPort) | ||
| log.Fatal(http.ListenAndServe(":"+*flagPort, mux)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| FROM registry.ci.openshift.org/rhcos-devel/rhel-coreos:latest | ||
| #We want to test it's only using the extensions repo | ||
| RUN rm -rf /etc/yum.repos.d/* | ||
| ADD ext.repo /etc/yum.repos.d/extension.repo | ||
| #Install usbguard as provided by the repo | ||
| RUN rpm-ostree install usbguard | ||
| RUN usbguard | ||
jmarrero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [ext] | ||
| name=extensions | ||
| baseurl=http://localhost:9091/ | ||
| enabled=1 | ||
| gpgcheck=1 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.