Commit f969b6aa authored by nanahira's avatar nanahira

rework dockerfile and ci

parent 0aba86a3
Pipeline #4792 failed with stages
in 15 seconds
stages:
- build
- build2
- combine
- deploy
variables:
GIT_DEPTH: "1"
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
CONTAINER_TEST_IMAGE_FULL: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-full
CONTAINER_TEST_IMAGE_LITE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-lite
CONTAINER_TEST_IMAGE_X86_FULL: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86-full
CONTAINER_TEST_IMAGE_X86_LITE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-x86-lite
CONTAINER_TEST_IMAGE_ARM_FULL: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm-full
CONTAINER_TEST_IMAGE_ARM_LITE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-arm-lite
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
CONTAINER_RELEASE_IMAGE_FULL: $CI_REGISTRY_IMAGE:full
CONTAINER_RELEASE_IMAGE_LITE: $CI_REGISTRY_IMAGE:lite
build:
build_lite_x86:
stage: build
tags:
- docker
variables:
TARGET_IMAGE: $CONTAINER_TEST_IMAGE_X86_LITE
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --pull --no-cache -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
build_lite:
- docker build --pull --no-cache -f ./Dockerfile.lite -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
build_lite_arm:
stage: build
tags:
- docker-arm
variables:
TARGET_IMAGE: $CONTAINER_TEST_IMAGE_ARM_LITE
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --pull --no-cache -f ./Dockerfile.lite -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
build_full_x86:
stage: build2
tags:
- docker
variables:
SOURCE_IMAGE: $CONTAINER_TEST_IMAGE_X86_LITE
TARGET_IMAGE: $CONTAINER_TEST_IMAGE_X86_FULL
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --build-arg BASE_IMAGE=$SOURCE_IMAGE --pull --no-cache -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
build_full_arm:
stage: build2
tags:
- docker-arm
variables:
SOURCE_IMAGE: $CONTAINER_TEST_IMAGE_ARM_LITE
TARGET_IMAGE: $CONTAINER_TEST_IMAGE_ARM_FULL
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --pull --no-cache -f ./Dockerfile.lite -t $CONTAINER_TEST_IMAGE_LITE .
- docker push $CONTAINER_TEST_IMAGE_LITE
- docker build --build-arg BASE_IMAGE=$SOURCE_IMAGE --pull --no-cache -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
combine_lite:
stage: build2
tags:
- docker
variables:
SOURCE_IMAGE_1: $CONTAINER_TEST_IMAGE_X86_LITE
SOURCE_IMAGE_2: $CONTAINER_TEST_IMAGE_ARM_LITE
TARGET_IMAGE: $CONTAINER_TEST_IMAGE_LITE
script:
- docker pull $SOURCE_IMAGE_1
- docker pull $SOURCE_IMAGE_2
- docker manifest create $TARGET_IMAGE --amend $SOURCE_IMAGE_1 --amend $SOURCE_IMAGE_2
- docker manifest push $TARGET_IMAGE
combine_full:
stage: combine
tags:
- docker
variables:
SOURCE_IMAGE_1: $CONTAINER_TEST_IMAGE_X86_FULL
SOURCE_IMAGE_2: $CONTAINER_TEST_IMAGE_ARM_FULL
TARGET_IMAGE: $CONTAINER_TEST_IMAGE_FULL
script:
- docker pull $SOURCE_IMAGE_1
- docker pull $SOURCE_IMAGE_2
- docker manifest create $TARGET_IMAGE --amend $SOURCE_IMAGE_1 --amend $SOURCE_IMAGE_2
- docker manifest push $TARGET_IMAGE
upload_stuff_to_minio:
stage: deploy
tags:
- linux
image: $CONTAINER_TEST_IMAGE
image: $CONTAINER_TEST_IMAGE_FULL
script:
- apt update ; apt -y install python3-pip
- pip3 install -U -i https://mirrors.aliyun.com/pypi/simple/ awscli
......@@ -42,35 +106,64 @@ upload_stuff_to_minio:
only:
- master
deploy_latest:
deploy_latest_full:
stage: deploy
tags:
- docker
variables:
SOURCE_IMAGE: $CONTAINER_TEST_IMAGE_FULL
TARGET_IMAGE: $CONTAINER_RELEASE_IMAGE_FULL
TARGET_IMAGE_2: $CONTAINER_RELEASE_IMAGE
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
- docker pull $CONTAINER_TEST_IMAGE_LITE
- docker tag $CONTAINER_TEST_IMAGE_LITE $CONTAINER_RELEASE_IMAGE_LITE
- docker push $CONTAINER_RELEASE_IMAGE_LITE
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE_2
- docker push $TARGET_IMAGE_2
only:
- master
deploy_tag:
deploy_latest_lite:
stage: deploy
tags:
- docker
variables:
CONTAINER_TAG_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
CONTAINER_TAG_IMAGE_LITE: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-lite
SOURCE_IMAGE: $CONTAINER_TEST_IMAGE_LITE
TARGET_IMAGE: $CONTAINER_RELEASE_IMAGE_LITE
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_TAG_IMAGE
- docker push $CONTAINER_TAG_IMAGE
- docker pull $CONTAINER_TEST_IMAGE_LITE
- docker tag $CONTAINER_TEST_IMAGE_LITE $CONTAINER_RELEASE_IMAGE_LITE
- docker push $CONTAINER_RELEASE_IMAGE_LITE
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
only:
- master
deploy_tag_full:
stage: deploy
tags:
- docker
variables:
SOURCE_IMAGE: $CONTAINER_TEST_IMAGE_FULL
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-full
TARGET_IMAGE_2: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
script:
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE_2
- docker push $TARGET_IMAGE_2
only:
- tags
deploy_tag_lite:
stage: deploy
tags:
- docker
variables:
SOURCE_IMAGE: $CONTAINER_TEST_IMAGE_LITE
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG-lite
script:
- docker pull $SOURCE_IMAGE
- docker tag $SOURCE_IMAGE $TARGET_IMAGE
- docker push $TARGET_IMAGE
only:
- tags
# Dockerfile for SRVPro
FROM debian:buster as premake-builder
RUN apt update && \
env DEBIAN_FRONTEND=noninteractive apt install -y wget build-essential p7zip-full && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
WORKDIR /usr/src
RUN wget -O premake.zip https://github.com/premake/premake-core/releases/download/v5.0.0-alpha14/premake-5.0.0-alpha14-src.zip && \
7z x -y premake.zip && \
mv premake-5.0.0-alpha14 premake && \
cd premake/build/gmake.unix && \
make -j$(nproc)
FROM node:14-buster-slim
ARG BASE_IMAGE=git-registry.mycard.moe/mycard/srvpro:lite
FROM $BASE_IMAGE
LABEL Author="Nanahira <nanahira@momobako.com>"
RUN npm install -g pm2
# apt
RUN apt update && \
env DEBIAN_FRONTEND=noninteractive apt install -y wget git build-essential libevent-dev libsqlite3-dev mono-complete p7zip-full python3 liblua5.3-dev python && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# srvpro
COPY . /ygopro-server
WORKDIR /ygopro-server
RUN npm ci && \
mkdir config decks replays logs
COPY --from=premake-builder /usr/src/premake/bin/release/premake5 /usr/bin/premake5
# ygopro
RUN git clone --branch=server --recursive --depth=1 https://github.com/moecube/ygopro && \
cd ygopro && \
git submodule foreach git checkout master && \
premake5 gmake && \
cd build && \
make config=release -j$(nproc) && \
cd .. && \
mv ./bin/release/ygopro . && \
strip ygopro && \
mkdir replay expansions && \
rm -rf .git* bin obj build ocgcore cmake lua premake* sound textures .travis.yml *.txt appveyor.yml LICENSE README.md *.lua strings.conf system.conf && \
ls gframe | sed '/game.cpp/d' | xargs -I {} rm -rf gframe/{}
# windbot
RUN git clone --depth=1 https://github.com/moecube/windbot /tmp/windbot && \
RUN git clone --depth=1 https://github.com/mycard/windbot /tmp/windbot && \
cd /tmp/windbot && \
xbuild /property:Configuration=Release /property:TargetFrameworkVersion="v4.5" && \
mv /tmp/windbot/bin/Release /ygopro-server/windbot && \
cp -rf /ygopro-server/ygopro/cards.cdb /ygopro-server/windbot/ && \
rm -rf /tmp/windbot
# infos
WORKDIR /ygopro-server
EXPOSE 7911 7922 7933
# VOLUME [ /ygopro-server/config, /ygopro-server/decks, /ygopro-server/replays, /redis ]
CMD [ "pm2-docker", "start", "/ygopro-server/data/pm2-docker.json" ]
# Dockerfile for SRVPro Lite
FROM debian:buster as premake-builder
FROM debian:bullseye as premake-builder
RUN apt update && \
env DEBIAN_FRONTEND=noninteractive apt install -y wget build-essential p7zip-full && \
......@@ -12,12 +12,13 @@ RUN wget -O premake.zip https://github.com/premake/premake-core/releases/downloa
cd premake/build/gmake.unix && \
make -j$(nproc)
FROM node:14-buster-slim
FROM node:16-bullseye-slim
LABEL Author="Nanahira <nanahira@momobako.com>"
# apt
RUN apt update && \
env DEBIAN_FRONTEND=noninteractive apt install -y wget git build-essential libsqlite3-dev libevent-dev p7zip-full python3 liblua5.3-dev python && \
rm -rf /var/lib/apt/lists/*
env DEBIAN_FRONTEND=noninteractive apt install -y wget git build-essential libevent-dev libsqlite3-dev mono-complete p7zip-full python3 python-is-python3 liblua5.3-dev && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# srvpro
COPY . /ygopro-server
......@@ -27,7 +28,7 @@ RUN npm ci && \
COPY --from=premake-builder /usr/src/premake/bin/release/premake5 /usr/bin/premake5
RUN git clone --branch=server --recursive --depth=1 https://github.com/moecube/ygopro && \
RUN git clone --branch=server --recursive --depth=1 https://code.mycard.moe/mycard/ygopro && \
cd ygopro && \
git submodule foreach git checkout master && \
premake5 gmake && \
......@@ -45,4 +46,4 @@ WORKDIR /ygopro-server
EXPOSE 7911 7922 7933
# VOLUME [ /ygopro-server/config, /ygopro-server/decks, /ygopro-server/replays ]
CMD [ "node", "ygopro-server.js" ]
CMD [ "npm", "start" ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment