Skip to content

Commit 77e31dd

Browse files
committed
Add docker
1 parent 09340c0 commit 77e31dd

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Rust
1+
name: Rust build
22

33
on:
44
push:
@@ -76,3 +76,41 @@ jobs:
7676
echo "$SFTP_KNOWN_HOSTS" > known_hosts
7777
chmod 600 known_hosts
7878
rsync -avz --delete -e "ssh -i sftp_key -o UserKnownHostsFile=known_hosts" output/docs/ $SFTP_USERNAME@$SFTP_HOST:/var/www/demo.luna.linwood
79+
build-docker:
80+
runs-on: ubuntu-24.04
81+
if: github.event_name != 'pull_request'
82+
steps:
83+
- name: ⬆️ Checkout
84+
uses: actions/checkout@v5
85+
- name: Set Docker tag
86+
id: docker_tag
87+
run: |
88+
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then
89+
echo "tag=latest" >> $GITHUB_ENV
90+
elif [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then
91+
echo "tag=dev" >> $GITHUB_ENV
92+
elif [[ "${GITHUB_REF}" == refs/tags/v* || "${GITHUB_REF}" == "refs/tags/stable" || "${GITHUB_REF}" == "refs/tags/nightly" ]]; then
93+
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
94+
else
95+
echo "tag=unknown" >> $GITHUB_ENV
96+
fi
97+
- name: Log Docker tag
98+
run: echo "Docker tag is ${{ env.tag }}"
99+
- name: Login to Docker Hub
100+
uses: docker/login-action@v3
101+
with:
102+
username: ${{ secrets.DOCKERHUB_USERNAME }}
103+
password: ${{ secrets.DOCKERHUB_TOKEN }}
104+
- name: Set up QEMU
105+
uses: docker/setup-qemu-action@v3
106+
- name: Set up Docker Buildx
107+
uses: docker/setup-buildx-action@v3
108+
- name: Build and push Docker image
109+
uses: docker/build-push-action@v6
110+
if: ${{ env.tag != 'unknown' }}
111+
with:
112+
context: .
113+
file: ./Dockerfile
114+
platforms: linux/amd64,linux/arm64
115+
push: true
116+
tags: linwooddev/luna:${{ env.tag }}

Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM rust:1-alpine AS builder
2+
WORKDIR /usr/src/luna
3+
COPY . .
4+
RUN apk add --no-cache build-base
5+
RUN cargo install --path ./cli --locked
6+
7+
FROM alpine:latest
8+
COPY --from=builder /usr/local/cargo/bin/luna_cli /usr/local/bin/luna_cli
9+
CMD ["luna_cli"]

0 commit comments

Comments
 (0)