docker: Add Dockerfile for multi-platforms.
This commit is contained in:
109
.github/workflows/build-nightly-cron.yaml
vendored
109
.github/workflows/build-nightly-cron.yaml
vendored
@@ -292,6 +292,7 @@ jobs:
|
||||
outputs:
|
||||
SPT_SERVER_COMMIT_TIME: ${{ steps.merge.outputs.SPT_SERVER_COMMIT_TIME }}
|
||||
LINUX_COMMIT_ID: ${{ steps.debug-info.outputs.COMMIT_ID }}
|
||||
LINUX_COMMIT_ID_WHOLE: ${{ steps.debug-info.outputs.COMMIT_ID_WHOLE }}
|
||||
LINUX_ARTIFACT: ${{ steps.filename.outputs.LINUX_ARTIFACT }}
|
||||
LINUX_RELEASE_FILE: ${{ steps.filename.outputs.LINUX_RELEASE }}
|
||||
LINUX_RELEASE_FIKA_FILE: ${{ steps.filename.outputs.LINUX_RELEASE_FIKA }}
|
||||
@@ -409,8 +410,9 @@ jobs:
|
||||
- name: Compress fika-server to docker dir
|
||||
run: |
|
||||
cd fika
|
||||
tar -czf ${{ env.SOURCECODE_DIR }}/docker/fika-server.tgz .
|
||||
ls -l ${{ env.SOURCECODE_DIR }}/docker
|
||||
tar -czf ${{ env.SOURCECODE_DIR }}/docker/FikaBuiltIn/fika-server.tgz .
|
||||
cp ${{ env.SOURCECODE_DIR }}/docker/spt-server.tgz ${{ env.SOURCECODE_DIR }}/docker/FikaBuiltIn
|
||||
ls -l ${{ env.SOURCECODE_DIR }}/docker/FikaBuiltIn
|
||||
shell: bash
|
||||
|
||||
- name: Extract metadata for Docker
|
||||
@@ -472,21 +474,20 @@ jobs:
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ steps.debug-info.outputs.COMMIT_ID_WHOLE }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64
|
||||
- name: Build and Push with Fika Server
|
||||
id: build-and-push-with-fika
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ${{ env.SOURCECODE_DIR }}/docker
|
||||
file: ${{ env.SOURCECODE_DIR }}/docker/Dockerfile-fika
|
||||
context: ${{ env.SOURCECODE_DIR }}/docker/FikaBuiltIn
|
||||
push: true
|
||||
tags: ${{ steps.meta-fika.outputs.tags }}
|
||||
labels: |
|
||||
${{ steps.meta.outputs.labels }}
|
||||
${{ steps.meta-fika.outputs.labels }}
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ steps.debug-info.outputs.COMMIT_ID_WHOLE }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64
|
||||
|
||||
- name: Push Linux Server Code
|
||||
run: |
|
||||
@@ -497,8 +498,98 @@ jobs:
|
||||
git push
|
||||
shell: bash
|
||||
|
||||
build-docker-image-multi-arch:
|
||||
needs: [prepare, build-server-linux]
|
||||
if: needs.prepare.outputs.PROCEED == 'true' || needs.prepare.outputs.PROCEED_FIKA == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKERHUB_USER: stblog
|
||||
DOCKERHUB_REPOSITORY: spt-server
|
||||
GHCR_USER: airryco
|
||||
GHCR_REPOSITORY: spt-server
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# docker
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPOSITORY }}
|
||||
ghcr.io/${{ env.GHCR_USER }}/${{ env.GHCR_REPOSITORY }}
|
||||
registry.cn-shenzhen.aliyuncs.com/spt-server/spt-server
|
||||
tags: |
|
||||
type=raw,value=nightly
|
||||
- name: Extract metadata for Docker with Fika-Server
|
||||
id: meta-fika
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPOSITORY }}
|
||||
ghcr.io/${{ env.GHCR_USER }}/${{ env.GHCR_REPOSITORY }}
|
||||
registry.cn-shenzhen.aliyuncs.com/spt-server/spt-server
|
||||
tags: |
|
||||
type=raw,value=nightly-fika
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# DockerHub
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
# GitHub Container Registry
|
||||
- name: Login to Github Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ env.GHCR_USER }}
|
||||
password: ${{ secrets.GHCR_TOKEN }}
|
||||
# Aliyun Registry
|
||||
- name: Login to Aliyun Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.cn-shenzhen.aliyuncs.com
|
||||
username: ${{ secrets.ALIYUN_REGISTRY_USER }}
|
||||
password: ${{ secrets.ALIYUN_REGISTRY_TOKEN }}
|
||||
|
||||
- name: Build and Push
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ./docker
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: |
|
||||
${{ steps.meta.outputs.labels }}
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }}
|
||||
platforms: linux/arm64
|
||||
- name: Build and Push with Fika Server
|
||||
id: build-and-push-with-fika
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ./docker
|
||||
file: ./docker/Dockerfile-fika
|
||||
push: true
|
||||
tags: ${{ steps.meta-fika.outputs.tags }}
|
||||
labels: |
|
||||
${{ steps.meta-fika.outputs.labels }}
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }}
|
||||
platforms: linux/arm64
|
||||
|
||||
update-trigger-and-push:
|
||||
needs: [prepare, build-server-windows, build-server-linux]
|
||||
needs: [prepare, build-server-windows, build-docker-image-multi-arch]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -528,8 +619,6 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Download Windows Artifact
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
104
.github/workflows/build-release-cron.yaml
vendored
104
.github/workflows/build-release-cron.yaml
vendored
@@ -208,6 +208,7 @@ jobs:
|
||||
GHCR_REPOSITORY: spt-server
|
||||
outputs:
|
||||
LINUX_COMMIT_ID: ${{ steps.debug-info.outputs.COMMIT_ID }}
|
||||
LINUX_COMMIT_ID_WHOLE: ${{ steps.debug-info.outputs.COMMIT_ID_WHOLE }}
|
||||
LINUX_ARTIFACT: ${{ steps.filename.outputs.LINUX_ARTIFACT }}
|
||||
LINUX_RELEASE_FILE: ${{ steps.filename.outputs.LINUX_RELEASE }}
|
||||
|
||||
@@ -370,8 +371,7 @@ jobs:
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ steps.debug-info.outputs.COMMIT_ID_WHOLE }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
platforms: linux/amd64
|
||||
- name: Build and Push For Latest
|
||||
if: ${{ !contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }}
|
||||
uses: docker/build-push-action@v6
|
||||
@@ -384,7 +384,7 @@ jobs:
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ steps.debug-info.outputs.COMMIT_ID_WHOLE }}
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64
|
||||
|
||||
- name: Push Linux Server Code And Tag
|
||||
run: |
|
||||
@@ -399,8 +399,104 @@ jobs:
|
||||
git push -u origin ${{ needs.prepare.outputs.TARGET_TAG }}
|
||||
shell: bash
|
||||
|
||||
build-docker-image-multi-arch:
|
||||
needs: [prepare, build-server-linux]
|
||||
if: needs.prepare.outputs.PROCEED == 'true' || needs.prepare.outputs.PROCEED_FIKA == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKERHUB_USER: stblog
|
||||
DOCKERHUB_REPOSITORY: spt-server
|
||||
GHCR_USER: airryco
|
||||
GHCR_REPOSITORY: spt-server
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# docker
|
||||
- name: Extract metadata for Docker with bem version
|
||||
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }}
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPOSITORY }}
|
||||
ghcr.io/${{ env.GHCR_USER }}/${{ env.GHCR_REPOSITORY }}
|
||||
registry.cn-shenzhen.aliyuncs.com/spt-server/spt-server
|
||||
tags: |
|
||||
type=semver,pattern={{version}},value=${{ needs.prepare.outputs.TARGET_TAG }}
|
||||
type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.TARGET_TAG }}
|
||||
- name: Extract metadata for Docker with latest version
|
||||
if: ${{ !contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }}
|
||||
id: meta-latest
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
${{ env.DOCKERHUB_USER }}/${{ env.DOCKERHUB_REPOSITORY }}
|
||||
ghcr.io/${{ env.GHCR_USER }}/${{ env.GHCR_REPOSITORY }}
|
||||
registry.cn-shenzhen.aliyuncs.com/spt-server/spt-server
|
||||
tags: |
|
||||
type=semver,pattern={{version}},value=${{ needs.prepare.outputs.TARGET_TAG }}
|
||||
type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare.outputs.TARGET_TAG }}
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# DockerHub
|
||||
- name: Login to Dockerhub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ env.DOCKERHUB_USER }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
# GitHub Container Registry
|
||||
- name: Login to Github Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ env.GHCR_USER }}
|
||||
password: ${{ secrets.GHCR_TOKEN }}
|
||||
# Aliyun Registry
|
||||
- name: Login to Aliyun Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.cn-shenzhen.aliyuncs.com
|
||||
username: ${{ secrets.ALIYUN_REGISTRY_USER }}
|
||||
password: ${{ secrets.ALIYUN_REGISTRY_TOKEN }}
|
||||
|
||||
- name: Build and Push For BEM
|
||||
if: ${{ contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }}
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ./docker
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: |
|
||||
${{ steps.meta.outputs.labels }}
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }}
|
||||
platforms: linux/arm64
|
||||
- name: Build and Push For Latest
|
||||
if: ${{ !contains(needs.prepare.outputs.TARGET_TAG, 'BEM') }}
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: ./docker
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: |
|
||||
${{ steps.meta.outputs.labels }}
|
||||
org.opencontainers.image.source=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.url=https://github.com/AirryCo/spt-server
|
||||
org.opencontainers.image.revision=${{ needs.build-server-linux.outputs.LINUX_COMMIT_ID_WHOLE }}
|
||||
platforms: linux/arm64
|
||||
|
||||
assemble-and-publish:
|
||||
needs: [prepare, build-server-windows, build-server-linux]
|
||||
needs: [prepare, build-server-windows, build-server-linux, build-docker-image-multi-arch]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
18
docker/Dockerfile
Normal file
18
docker/Dockerfile
Normal file
@@ -0,0 +1,18 @@
|
||||
FROM node:20.11.1-alpine AS server-builder
|
||||
RUN apk add --no-cache git git-lfs && \
|
||||
git clone -b 3.10.0-DEV https://github.com/AirryCo/spt-server.git /spt-server && \
|
||||
cd /spt-server && git lfs pull && \
|
||||
cd project && \
|
||||
npm install && npm run build:release
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
LABEL author="AirryCo <henry@stblog.com.cn>"
|
||||
ENV TZ=Asia/Shanghai
|
||||
COPY --from=server-builder /spt-server/project/build/ /app/spt-server/
|
||||
VOLUME /opt/spt-server
|
||||
WORKDIR /opt/spt-server
|
||||
EXPOSE 6969
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
26
docker/Dockerfile-fika
Normal file
26
docker/Dockerfile-fika
Normal file
@@ -0,0 +1,26 @@
|
||||
FROM node:20.11.1-alpine AS fika-builder
|
||||
RUN apk add --no-cache git git-lfs unzip && \
|
||||
git clone -b spt-3.10 https://github.com/project-fika/Fika-Server.git /fika-server && \
|
||||
cd /fika-server && \
|
||||
npm install && npm run build && \
|
||||
mkdir output && cd output && unzip /fika-server/dist/fika-server.zip
|
||||
|
||||
FROM node:20.11.1-alpine AS server-builder
|
||||
RUN apk add --no-cache git git-lfs && \
|
||||
git clone -b 3.10.0-DEV https://github.com/AirryCo/spt-server.git /spt-server && \
|
||||
cd /spt-server && git lfs pull && \
|
||||
cd project && \
|
||||
npm install && npm run build:release
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
LABEL author="AirryCo <henry@stblog.com.cn>"
|
||||
ENV TZ=Asia/Shanghai
|
||||
COPY --from=server-builder /spt-server/project/build/ /app/spt-server/
|
||||
COPY --from=fika-builder /fika-server/output/ /app/spt-server/
|
||||
VOLUME /opt/spt-server
|
||||
WORKDIR /opt/spt-server
|
||||
EXPOSE 6969
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
37
docker/entrypoint.sh
Normal file
37
docker/entrypoint.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -f /opt/spt-server/SPT.Server ]; then
|
||||
appHash=$(md5sum /app/spt-server/SPT.Server | awk '{ print $1 }')
|
||||
optHash=$(md5sum /opt/spt-server/SPT.Server | awk '{ print $1 }')
|
||||
if [ "$appHash" = "$optHash" ]; then
|
||||
echo "MD5 verification successful!"
|
||||
else
|
||||
echo "MD5 mismatch, copy files to /opt/spt-server."
|
||||
cp -r /app/spt-server /opt
|
||||
echo "Finished!"
|
||||
fi
|
||||
else
|
||||
echo "Program is not found, copy files to /opt/spt-server."
|
||||
cp -r /app/spt-server /opt
|
||||
echo "Finished!"
|
||||
fi
|
||||
|
||||
cd /opt/spt-server
|
||||
|
||||
if [ -z "$backendIp" ]; then
|
||||
IP=$(hostname -I | awk '{print $1}')
|
||||
else
|
||||
IP=$backendIp
|
||||
fi
|
||||
|
||||
if [ -z "$backendPort" ]; then
|
||||
PORT=6969
|
||||
else
|
||||
PORT=$backendPort
|
||||
fi
|
||||
|
||||
sed -i "0,/127.0.0.1/s/127.0.0.1/${IP}/" SPT_Data/Server/configs/http.json
|
||||
sed -i "s/6969/${PORT}/g" SPT_Data/Server/configs/http.json
|
||||
|
||||
chmod +x SPT.Server && ./SPT.Server
|
||||
|
||||
Reference in New Issue
Block a user