feat: inital version of a static webserver
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Rick Barenthin 2022-08-01 14:24:25 +02:00
parent 4ef62959d0
commit 4ec37438b3
5 changed files with 154 additions and 1 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
*

120
.drone.yml Normal file
View File

@ -0,0 +1,120 @@
---
kind: pipeline
type: docker
name: main
steps:
- name: Fetch tags
image: alpine/git
commands:
- git fetch --tags
- name: Update version and changelog
image: registry.riba-interactive.de/conventi:0.1.0
- name: Commit changelog updates
image: alpine/git
commands:
- git add .
- git commit -m "version and changelog update [CI SKIP]"
- git push origin $DRONE_TARGET_BRANCH
- name: Tag commit
image: registry.riba-interactive.de/conventi:0.1.0
commands:
- export VERSION=$(conventi.sh get_version)
- git tag -am "Tagging new version $VERSION" "$VERSION"
- git push origin "$VERSION"
trigger:
branch:
- main
event:
- push
image_pull_secrets:
- dockerconfig
---
kind: pipeline
type: docker
name: tag
steps:
- name: Build release
image: docker:dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_USER:
from_secret: docker_user
DOCKER_PASSWORD:
from_secret: docker_password
commands:
- sleep 5 # give docker enough time to start
- echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USER --password-stdin registry.riba-interactive.de
- docker pull registry.riba-interactive.de/statically:latest || true
- DOCKER_BUILDKIT=1 docker build --cache-from registry.riba-interactive.de/statically:latest --tag registry.riba-interactive.de/statically:latest .
- docker tag registry.riba-interactive.de/statically:latest registry.riba-interactive.de/statically:$DRONE_TAG
- docker push --all-tags registry.riba-interactive.de/statically
trigger:
event:
- tag
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
image_pull_secrets:
- dockerconfig
---
kind: pipeline
type: docker
name: Build and Test
steps:
- name: Build image
image: docker:dind
volumes:
- name: dockersock
path: /var/run
environment:
DOCKER_USER:
from_secret: docker_user
DOCKER_PASSWORD:
from_secret: docker_password
commands:
- sleep 5 # give docker enough time to start
- echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USER --password-stdin registry.riba-interactive.de
- docker pull registry.riba-interactive.de/statically:latest || true
- DOCKER_BUILDKIT=1 docker build --cache-from registry.riba-interactive.de/statically:latest --tag registry.riba-interactive.de/statically:latest .
- docker tag registry.riba-interactive.de/statically:latest registry.riba-interactive.de/statically:build-$DRONE_BUILD_NUMBER
- docker push --all-tags registry.riba-interactive.de/statically
trigger:
branch:
- develop
- feature/*
- bugfix/*
services:
- name: docker
image: docker:dind
privileged: true
volumes:
- name: dockersock
path: /var/run
volumes:
- name: dockersock
temp: {}
image_pull_secrets:
- dockerconfig
...

31
Dockerfile Normal file
View File

@ -0,0 +1,31 @@
FROM alpine:3.16.0 AS builder
ARG THTTPD_VERSION=2.29
RUN apk add gcc musl-dev make
RUN wget http://www.acme.com/software/thttpd/thttpd-${THTTPD_VERSION}.tar.gz \
&& tar xzf thttpd-${THTTPD_VERSION}.tar.gz \
&& mv /thttpd-${THTTPD_VERSION} /thttpd
RUN cd /thttpd \
&& ./configure \
&& make CCOPT='-O2 -s -static' thttpd
RUN adduser -D www --home /var/www
FROM scratch
EXPOSE 3000
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /thttpd/thttpd /usr/local/bin/
USER www
WORKDIR /var/www/htdocs
# Copy the static website
# Use the .dockerignore file to control what ends up inside the image!
COPY . .
# Run thttpd
CMD ["/usr/local/bin/thttpd", "-D", "-h", "0.0.0.0", "-p", "3000", "-d", "/var/www/htdocs", "-u", "www", "-l", "-", "-M", "60"]

View File

@ -1,4 +1,4 @@
Copyright (c) year copyright holder. All Rights Reserved.
Copyright (c) 2022 Rick Barenthin. All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

View File

@ -1,2 +1,3 @@
# statically
[![Build Status](https://drone.riba-interactive.de/api/badges/rick/statically/status.svg)](https://drone.riba-interactive.de/rick/statically)