Build a Docker image
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Sam A. 2024-02-10 17:59:05 +01:00
parent 564f508b99
commit 11affc28d6
Signed by: samsapti
GPG key ID: CBBBE7371E81C4EA
3 changed files with 27 additions and 15 deletions

View file

@ -1,9 +1,9 @@
kind: pipeline kind: pipeline
type: docker type: docker
name: Build and Deploy name: Build and Deplo
steps: steps:
- name: build - name: Build site with Hugo
image: klakegg/hugo:ext-alpine-ci image: klakegg/hugo:ext-alpine-ci
environment: environment:
HUGO_SECURITY_HTTP_URLS: none HUGO_SECURITY_HTTP_URLS: none
@ -12,18 +12,17 @@ steps:
- git submodule update --init --single-branch --depth=1 - git submodule update --init --single-branch --depth=1
- hugo - hugo
- name: deploy - name: Build and push Docker image
image: alpine:latest image: plugins/docker
environment: settings:
SSH_KEY: repo: samsapti/website
from_secret: ssh_key username:
commands: from_secret: DOCKER_USERNAME
- apk add --no-cache openssh-client rsync password:
- mkdir ~/.ssh from_secret: DOCKER_PASSWORD
- echo "$${SSH_KEY}" > ~/.ssh/id_ed25519 tags:
- chmod 600 ~/.ssh/id_ed25519 - "${DRONE_BUILD_NUMBER}"
- ssh-keyscan -H cpx.servers.sapti.me > ~/.ssh/known_hosts - latest
- rsync -acvx --delete ./public cicd@cpx.servers.sapti.me:/opt/docker/samsapti.dev/
when: when:
branch: branch:
- main - main

4
Dockerfile Normal file
View file

@ -0,0 +1,4 @@
FROM nginx:alpine-slim
COPY nginx.conf /etc/nginx/conf.d/web.conf
COPY public/ /usr/share/nginx/html/

9
nginx.conf Normal file
View file

@ -0,0 +1,9 @@
access_log off;
add_header Connection "Keep-Alive" always;
add_header Content-Security-Policy "default-src 'none'; child-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; form-action 'self'; font-src 'self'; frame-ancestors 'self'; base-uri 'self'; connect-src 'self'; img-src 'self'; manifest-src 'self'" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Permissions-Policy "accelerometer=(),ambient-light-sensor=(),autoplay=(),camera=(),encrypted-media=(),focus-without-user-activation=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(),speaker=(),sync-xhr=(),usb=(),vr=(),interest-cohort=()" always;
add_header Referrer-Policy "no-referrer" always;
add_header Cache-Control "max-age=3600" always;