diff --git a/Containerfile b/Containerfile index 2851af6..ab6e2d7 100644 --- a/Containerfile +++ b/Containerfile @@ -4,4 +4,4 @@ MAINTAINER philo email phil.dev@philome.mooo.com EXPOSE 80 COPY nginx.conf /etc/nginx/nginx.conf -COPY treetrail-app/dist/treetrail/browser /usr/share/nginx/html \ No newline at end of file +COPY dist/treetrail/browser /usr/share/nginx/html diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..9501b13 --- /dev/null +++ b/build.yaml @@ -0,0 +1,33 @@ +- name: Build containers + hosts: localhost + tasks: + - name: Install dependencies + command: pnpm install + args: + chdir: "{{ playbook_dir }}" + + - name: Build the Angular app + command: ng build + args: + chdir: "{{ playbook_dir }}" + + - name: Get the version from git + command: git describe --dirty --tags + register: version + args: + chdir: "{{ playbook_dir }}" + + - name: Build frontend container + containers.podman.podman_image: + name: "treetrail-frontend:{{ version.stdout }}" + state: build + path: "{{ playbook_dir }}" + build: + format: oci + force_rm: yes + cache: no + file: Containerfile + #quadlet_options: + # - | + # [Install] + # WantedBy=default.target diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..6703859 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,65 @@ +events { + worker_connections 1024; ## Default: 1024 +} + +http { + + ## use mime types + include /etc/nginx/mime.types; + + server { + + listen 80 default_server; + server_name _; + root /usr/share/nginx/html; + + location = / { + ## Convevience redirect to redirect to the web root + return 301 /treetrail/; + } + + location = /treetrail { + ## Convevience redirect to redirect to the web root + return 301 /treetrail/; + } + + location /treetrail/ { + alias /usr/share/nginx/html/; + index index.html; + try_files $uri $uri/ /index.html; + } + + location /treetrail/v1/ { + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_redirect off; + proxy_buffering off; + proxy_pass http://127.0.0.1:8081; + } + } + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + ## enable gzip compression + gzip on; + gzip_vary on; + gzip_min_length 256; + gzip_proxied any; + + gzip_types + ## text/html is always compressed : https://nginx.org/en/docs/http/ngx_http_gzip_module.html + text/plain + text/css + text/javascript + application/javascript + application/x-javascript + application/xml + application/json + application/ld+json; +}