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

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;