Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker support #11

Merged
merged 4 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ jobs:
- name: Build
run: cargo build
- name: Run tests
run: cargo test --release
run: cargo test --release

build-docker:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build and test for Docker
run: docker build -f docker/Dockerfile --target test .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/images
34 changes: 34 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM rust:alpine as base

WORKDIR /code

COPY Cargo.toml .
COPY Cargo.lock .
COPY src/ src/

RUN apk update && apk add g++ zlib zlib-dev

RUN cargo fetch --locked

# Run tests
FROM base as test

RUN cargo test --release

# Build binary
FROM test as build

RUN cargo build --release

# Package image
FROM alpine as production

WORKDIR /home/rust/

RUN apk update && apk add supervisor

COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

COPY --from=build /code/target/release/satpaper .

CMD [ "/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf" ]
13 changes: 13 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: satpaper
services:
satpaper:
build:
context: ../
dockerfile: ./docker/Dockerfile
environment:
- SATPAPER_SATELLITE=goes-east
- SATPAPER_RESOLUTION_X=2560
- SATPAPER_RESOLUTION_Y=1440
- SATPAPER_DISK_SIZE=95
volumes:
- ../images:/home/rust/images
27 changes: 27 additions & 0 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[supervisord]
user=root
logfile=/dev/null
logfile_maxbytes=0
loglevel=info
nodaemon=true

[program:satpaper]
command=/home/rust/satpaper
process_name=%(program_name)s
numprocs=1
directory=/home/rust
umask=022
priority=999
autostart=true
autorestart=unexpected
startsecs=10
startretries=10
exitcodes=0,2
stopsignal=TERM
stopwaitsecs=10
stopasgroup=false
killasgroup=false
redirect_stderr=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
environment=XDG_CURRENT_DESKTOP="GNOPE",SATPAPER_WALLPAPER_COMMAND="echo",SATPAPER_TARGET_PATH="/home/rust/images"