Skip to content

Commit

Permalink
use ubuntu to build docker
Browse files Browse the repository at this point in the history
  • Loading branch information
zenuo committed Jul 18, 2024
1 parent 4eac106 commit 5f7da1b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
33 changes: 21 additions & 12 deletions .github/workflows/ci_server_and_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
- ".github/workflows/ci_server_and_web.yml"
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
ALPINE_RUST_TARGET: x86_64-unknown-linux-musl

jobs:
build-web:
if: ${{!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')}}
Expand Down Expand Up @@ -112,19 +117,10 @@ jobs:
needs: [build-web]
if: ${{!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')}}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
container:
image: rust:alpine
volumes:
- ./gogo-server:/gogo-server
env:
RUST_TARGET: x86_64-unknown-linux-musl
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Clone repo
uses: actions/checkout@v4
Expand All @@ -134,7 +130,7 @@ jobs:
run: |
ls -lh
cd gogo-server
cargo build --release --target ${{ env.RUST_TARGET }}
cargo build --release --target ${{ env.ALPINE_RUST_TARGET }}
- name: Package
run: |
ls -lh
Expand All @@ -149,9 +145,18 @@ jobs:
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: server-web-${{ env.RUST_TARGET }}
name: server-web-${{ env.ALPINE_RUST_TARGET }}
path: package/
retention-days: 7

build-docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
Expand All @@ -163,6 +168,10 @@ jobs:
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Download web package
uses: actions/download-artifact@v4
with:
name: server-web-${{ env.ALPINE_RUST_TARGET }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
Expand All @@ -177,4 +186,4 @@ jobs:
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
push-to-registry: true
7 changes: 3 additions & 4 deletions Dockerfile_workflow
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM alpine:3.16
WORKDIR /opt/
RUN apk upgrade --no-cache && apk add --no-cache openssl libgcc
COPY package/gogo-server .
COPY package/config.json .
COPY package/gogo-web .
EXPOSE 4998
COPY gogo-server .
COPY config.json .
COPY gogo-web .
ENTRYPOINT ["/opt/gogo-server","config.json"]

0 comments on commit 5f7da1b

Please sign in to comment.