-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-setup.sh
47 lines (34 loc) · 1009 Bytes
/
docker-setup.sh
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
#!/bin/sh
echo "The build environment consists of the following files:"
find /src
set -euxo pipefail
# Clean up any defaults
rm -rf /etc/nginx/nginx.conf /etc/nginx/conf.d /var/lib/nginx /var/www
# Set up Nginx folders
mkdir -p /run/nginx
mkdir -p /var/www
mkdir -p /var/log/nginx
mkdir -p /var/lib/nginx/logs
# And non-root user for Nginx to run as
adduser -D -g www www
# Set up Nginx configuration in place
cp -r /src/nginx/* /etc/nginx
# Build the contents to be published
cd /src/gatsby
npm install
npm run build
# Publish everything necessary
cd /src/gatsby/public/
cp -r . /var/www/
cp -r /src/cmsadmin /var/www/
# Set permissions
chown -R www:www /var/www /var/log/nginx /var/lib/nginx/logs
# Clean up files not needed in final container
rm -rf /src/gatsby /src/nginx /src/cmsadmin /root/.npm /tmp/* /src/.git
rm -rf /src/*.md /src/docs /src/Dockerfile
rm -rf /src/.github /src/LICENSE
# Show in logs what we're publishing
set +x
cd /var/www
echo "Ready to publish the following:"
find .