-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
microcloud/charms/setup: local image server for faster development it…
…erations Signed-off-by: Gabriel Mougard <gabriel.mougard@canonical.com>
- Loading branch information
1 parent
1e59c10
commit 834dc2d
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
FROM nginx:latest | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf |
47 changes: 47 additions & 0 deletions
47
microcloud/charms/setup/local-maas-image-server/nginx.conf
This file contains 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,47 @@ | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
# Improve performance by turning on sendfile and adjusting other parameters | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
client_max_body_size 5g; | ||
|
||
# Compression reduces the response size and improves the speed | ||
gzip on; | ||
gzip_min_length 10240; | ||
gzip_proxied expired no-cache no-store private auth; | ||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml; | ||
gzip_disable "MSIE [1-6]\."; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
server { | ||
listen 80; | ||
server_name 0.0.0.0; | ||
|
||
# Point to the Simplestreams data directory | ||
root /usr/share/maas/images/ephemeral-v3/stable; | ||
|
||
location / { | ||
expires 30d; | ||
add_header Cache-Control "public, max-age=2592000"; | ||
try_files $uri $uri/ =404; | ||
} | ||
} | ||
} |
This file contains 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,26 @@ | ||
#!/bin/bash | ||
|
||
HOST_PATH="/usr/share/maas/images" | ||
|
||
if [ ! -d "$HOST_PATH" ]; then | ||
echo "Warning: Directory $HOST_PATH does not exist. Creating folder..." | ||
sudo mkdir -p $HOST_PATH | ||
fi | ||
|
||
KEYRING_FILE=/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg | ||
IMAGE_SRC=https://images.maas.io/ephemeral-v3/stable | ||
IMAGE_DIR=/usr/share/maas/images/ephemeral-v3/stable | ||
|
||
sudo sstream-mirror \ | ||
--keyring=$KEYRING_FILE $IMAGE_SRC $IMAGE_DIR \ | ||
'arch=amd64' 'release~(jammy)' --max=1 --progress | ||
|
||
sudo sstream-mirror \ | ||
--keyring=$KEYRING_FILE $IMAGE_SRC $IMAGE_DIR \ | ||
'os~(grub*|pxelinux)' --max=1 --progress | ||
|
||
docker build -t nginx-maas-image-server . | ||
docker run --name local-maas-image-server \ | ||
-d -p 5000:80 \ | ||
-v $HOST_PATH/ephemeral-v3/stable:/usr/share/maas/images/ephemeral-v3/stable \ | ||
nginx-maas-image-server |