forked from kwk/docker-registry-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
118 lines (89 loc) · 3.4 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
################################################################################
# Stage 1: Build the Angluar application
################################################################################
FROM node:8-alpine as build_app
LABEL maintainer="Konrad Kleine"
ENV WORKDIR=/usr/src
RUN mkdir -p $WORKDIR \
$WORKDIR/.git
WORKDIR $WORKDIR
# The node image removes these packages as they are only needed to build node not to run it
# Since we are installing/building npm packages will need these in the image
RUN apk add --no-cache --virtual .build-deps \
automake \
autoconf \
gcc \
g++ \
make \
nasm \
python \
zlib-dev
COPY . $WORKDIR
RUN npm install \
&& apk del .build-deps
# Add some git files for versioning
ADD .git/HEAD $WORKDIR/.git/HEAD
ADD .git/refs $WORKDIR/.git/refs
# Create version file
RUN export GITREF=$(cat .git/HEAD | cut -d" " -f2) && \
export GITSHA1=$(cat .git/$GITREF) && \
echo "{\"git\": {\"sha1\": \"$GITSHA1\", \"ref\": \"$GITREF\"}}" > app-version.json
## Build App
RUN node_modules/grunt-cli/bin/grunt build --allow-root
################################################################################
# Stage 2: Run the Angular application
################################################################################
FROM debian:jessie
LABEL maintainer="Konrad Kleine"
USER root
############################################################
# Setup environment variables
############################################################
ENV WWW_DIR /var/www/html
ENV START_SCRIPT /root/start-apache.sh
RUN mkdir -pv $WWW_DIR
############################################################
# Speedup DPKG and don't use cache for packages
############################################################
# Taken from here: https://gist.github.com/kwk/55bb5b6a4b7457bef38d
#
# this forces dpkg not to call sync() after package extraction and speeds up
# install
RUN echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup
# # we don't need and apt cache in a container
RUN echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache
############################################################
COPY --from=build_app /usr/src/dist/ $WWW_DIR/
COPY --from=build_app /usr/src/app-version.json $WWW_DIR/app-version.json
############################################################
# Install and configure webserver software
############################################################
RUN apt-get -y update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get -y install \
apache2 \
libapache2-mod-auth-kerb \
libapache2-mod-proxy-html \
--no-install-recommends && \
a2enmod proxy && \
a2enmod proxy_http && \
apt-get -y autoremove && \
apt-get -y clean && \
rm -rf /var/lib/apt/lists/*
############################################################
# Add and enable the apache site and disable all other sites
############################################################
RUN a2dissite 000*
ADD apache-site.conf /etc/apache2/sites-available/docker-site.conf
RUN a2ensite docker-site.conf
ADD start-apache.sh $START_SCRIPT
RUN chmod +x $START_SCRIPT
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
# Let people know how this was built
ADD Dockerfile /root/Dockerfile
# Exposed ports
EXPOSE 80 443
VOLUME ["/etc/apache2/server.crt", "/etc/apache2/server.key"]
CMD $START_SCRIPT