Added Dockerfile & CI deploy
parent
c18cb8aede
commit
4a99bb938c
|
@ -0,0 +1,5 @@
|
|||
*
|
||||
|
||||
!src/
|
||||
!Cargo.toml
|
||||
!Cargo.lock
|
|
@ -1 +1,2 @@
|
|||
/target
|
||||
/data/
|
||||
|
|
|
@ -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
|
|
@ -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]
|
||||
|
|
|
@ -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" ]
|
||||
|
||||
|
Loading…
Reference in New Issue