Added Dockerfile & CI deploy

pull/1/head
Jef Roosens 2022-04-02 13:45:04 +02:00
parent c18cb8aede
commit 4a99bb938c
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
5 changed files with 74 additions and 0 deletions

5
.dockerignore 100644
View File

@ -0,0 +1,5 @@
*
!src/
!Cargo.toml
!Cargo.lock

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
/data/

23
.woodpecker.yml 100644
View File

@ -0,0 +1,23 @@
platform: linux/amd64
branch: main
pipeline:
release:
image: 'plugins/docker'
settings:
repo: 'chewingbever/site'
tag:
- 'latest'
- "${CI_COMMIT_TAG}"
secrets:
- 'docker_username'
- 'docker_password'
event: tag
deploy:
image: 'curlimages/curl'
secrets:
- 'webhook'
commands:
- curl -XPOST --fail -s "$WEBHOOK"
event: tag

View File

@ -4,6 +4,10 @@ version = "0.0.0"
edition = "2021"
publish = false
[[bin]]
path = "src/main.rs"
name = "site"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

41
Dockerfile 100644
View File

@ -0,0 +1,41 @@
FROM rust:1.59-alpine3.15 AS builder
ARG DI_VER=1.2.5
WORKDIR /app
RUN apk update && apk add --no-cache build-base
# Build dumb-init
RUN wget -O - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \
cd "dumb-init-${DI_VER}" && \
make SHELL=/bin/sh && \
mv dumb-init .. && \
cd ..
COPY . ./
RUN cargo build --release
FROM alpine:3.15
COPY --from=builder /app/target/release/site /bin/site
COPY --from=builder /app/dumb-init /bin/dumb-init
# Create a non-root user & make sure it can write to the data directory
RUN set -x && \
adduser -u 82 -D -S -G www-data www-data && \
mkdir /data && \
chown -R www-data:www-data /data
ENV DATA_DIR=/data
WORKDIR /data
USER www-data:www-data
ENTRYPOINT [ "/bin/dumb-init", "--" ]
CMD [ "/bin/site" ]