-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
68 lines (56 loc) · 3.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
FROM nginx:mainline-alpine3.18
LABEL creator Thomas HERBIN
ARG S3_URI
RUN apk add --no-cache \
python3 \
py3-pip \
py3-six \
wget \
&& apk add --upgrade --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/community rpm \
&& apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing createrepo_c \
&& pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir \
awscli \
&& rm -rf /var/cache/apk/* ;
WORKDIR /tmp
COPY generate_updateinfo.py /tmp
COPY nginx-repo.conf /etc/nginx/conf.d/default.conf
## Create Repo directories and remove index file to browse the server files freely
RUN mkdir /usr/share/nginx/html/errata5 \
/usr/share/nginx/html/errata6 \
/usr/share/nginx/html/errata7 \
/usr/share/nginx/html/errata8 \
&& rm /usr/share/nginx/html/index.html
## Create Repo metadata
RUN createrepo_c --general-compress-type=gz -v /usr/share/nginx/html/errata5 \
&& createrepo_c --general-compress-type=gz -v /usr/share/nginx/html/errata6 \
&& createrepo_c --general-compress-type=gz -v /usr/share/nginx/html/errata7 \
&& createrepo_c --general-compress-type=gz -v /usr/share/nginx/html/errata8
## Get the errata file from CEFS, check the sha1sum and convert the file to compatible "yum repository" updateinfo.xml files
## Then we put the file in the repository
RUN wget http://cefs.steve-meier.de/errata.latest.xml.bz2 \
&& wget -qO- http://cefs.steve-meier.de/errata.latest.sha1 | grep bz2 > check.sha1 && sha1sum -c check.sha1 \
&& bzip2 -dc errata.latest.xml.bz2 > errata.latest.xml \
&& ./generate_updateinfo.py -s all -t all -v -d ./ errata.latest.xml \
&& rm -rf errata.latest.xml* \
\
&& mv /tmp/updateinfo-5/updateinfo.xml /usr/share/nginx/html/errata5/repodata/ \
&& mv /tmp/updateinfo-6/updateinfo.xml /usr/share/nginx/html/errata6/repodata/ \
&& mv /tmp/updateinfo-7/updateinfo.xml /usr/share/nginx/html/errata7/repodata/ \
&& mv /tmp/updateinfo-8/updateinfo.xml /usr/share/nginx/html/errata8/repodata/
## Tell the repository that it now contains errata
RUN modifyrepo_c --compress-type=gzip /usr/share/nginx/html/errata5/repodata/updateinfo.xml /usr/share/nginx/html/errata5/repodata \
&& modifyrepo_c --compress-type=gzip /usr/share/nginx/html/errata6/repodata/updateinfo.xml /usr/share/nginx/html/errata6/repodata \
&& modifyrepo_c --compress-type=gzip /usr/share/nginx/html/errata7/repodata/updateinfo.xml /usr/share/nginx/html/errata7/repodata \
&& modifyrepo_c --compress-type=gzip /usr/share/nginx/html/errata8/repodata/updateinfo.xml /usr/share/nginx/html/errata8/repodata
## Exit if no bucket is provided
## If you wish to run this container as the nginx server, you can comment everything below
RUN echo "checking S3 Bucket" && \
if [ -z "${S3_URI}" ]; \
then \
echo "missing ENV Variable : S3_URI" \
&& echo "you should provide the S3_URI in the form : S3_URI=s3://yourbucket/" \
&& exit 1; \
fi
RUN echo "retrieving config file from URI ${S3_URI}" \
&& aws s3 cp /usr/share/nginx/html ${S3_URI} --recursive