Skip to content

Commit

Permalink
extensions: Add container to serve repository with extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrero committed Jul 5, 2022
1 parent c492063 commit d98d30b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
25 changes: 25 additions & 0 deletions extensions/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Builds the webserver for the repo service.
FROM golang as gobuild
ADD repo-server/main.go .
RUN mkdir /build
RUN go build -o /build/webserver main.go

## Downloads the extensions given the extensions.yaml
ARG RHCOS_VERSION=latest
FROM registry.ci.openshift.org/rhcos-devel/rhel-coreos:${RHCOS_VERSION} as os
#Expects repos from redhat-coreos, like when building rhcos locally.
RUN rpm-ostree compose extensions --rootfs=/ --output-dir=/usr/share/rpm-ostree/extensions/ {manifest,extensions}.yaml

## Creates the repo metadata for the extensions
FROM quay.io/centos/centos:stream8 as repo
COPY --from=os /usr/share/rpm-ostree/extensions/ /usr/share/rpm-ostree/extensions/
RUN dnf install -y createrepo_c
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=gobuild /build/webserver /usr/bin/webserver
COPY --from=repo /usr/share/rpm-ostree/extensions/ /usr/share/rpm-ostree/extensions/

CMD ["./usr/bin/webserver"]
EXPOSE 9666/tcp
22 changes: 22 additions & 0 deletions extensions/repo-server/main.go
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", "9666", "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))
}
7 changes: 7 additions & 0 deletions extensions/test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM registry.ci.openshift.org/rhcos-devel/rhel-coreos:4.11
#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/extention.repo
#Install usbguard as provided by the repo
RUN rpm-ostree install usbguard
RUN usbguard
5 changes: 5 additions & 0 deletions extensions/test/ext.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[ext]
name=extensions
baseurl=http://localhost:9666/
enabled=1
gpgcheck=0

0 comments on commit d98d30b

Please sign in to comment.