From 2a6efff2e4d2127d2d739592582efd66bc22c64f Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:18:31 +0000 Subject: [PATCH 1/3] feat: Add Dockerfile and GitHub Actions for automated publishing This change introduces a comprehensive Dockerfile and a GitHub Actions workflow to build and publish a custom Docker image from the project's source code. - A new `Dockerfile` has been added. It builds the application from the local source, installing all necessary dependencies, ensuring that any modifications to the codebase are included in the final image. This approach is consistent with the build process of `linuxserver/grocy`. - The Docker image is configured to use Chinese (`zh_CN`) as the default language via the `GROCY_DEFAULT_LOCALE` environment variable. - A GitHub Actions workflow is added to `.github/workflows/docker-publish.yml`. It automates the process of building and publishing the image to `nishizhen/anticlockwisegrocy` on Docker Hub whenever a push is made to the `master` branch. - The `README.md` has been updated to reflect the new Docker image and provide correct instructions for its use. --- .github/workflows/docker-publish.yml | 33 ++++++++++++++ Dockerfile | 67 ++++++++++++++++++++++++++++ README.md | 23 +++++++++- 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-publish.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 00000000..cb760b9a --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,33 @@ +name: Docker Publish + +on: + push: + branches: + - master + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: nishizhen/anticlockwisegrocy + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c24c3728 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,67 @@ +# Use the same base image as linuxserver/grocy for consistency +FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.21 + +# Set the default language to Chinese +ENV GROCY_DEFAULT_LOCALE=zh_CN + +# Install build and runtime dependencies, same as linuxserver/grocy +RUN \ + echo "**** install build packages ****" && \ + apk add --no-cache --virtual=build-dependencies \ + git \ + yarn \ + composer && \ + echo "**** install runtime packages ****" && \ + apk add --no-cache \ + php83-gd \ + php83-intl \ + php83-ldap \ + php83-opcache \ + php83-pdo \ + php83-pdo_sqlite \ + php83-tokenizer \ + php83-fileinfo \ + php83-ctype \ + php83-zlib \ + php83-mbstring && \ + echo "**** configure php-fpm to pass env vars ****" && \ + sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php83/php-fpm.d/www.conf && \ + grep -qxF 'clear_env = no' /etc/php83/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php83/php-fpm.d/www.conf + +# Set up the application directory +RUN mkdir -p /app/www/ + +# Copy the application source code into the container +# We are in the root of the project, so this copies everything +COPY . /app/www/ + +# Set correct permissions for the web server to write to the data directory +# The base image's init system will set ownership for /app, but let's ensure permissions are correct. +RUN chmod -R 777 /app/www/data + +# Install dependencies and perform cleanup +RUN \ + echo "**** install composer packages ****" && \ + composer install -d /app/www --no-dev --optimize-autoloader && \ + echo "**** install yarn packages ****" && \ + cd /app/www && \ + yarn --production && \ + yarn cache clean && \ + echo "**** cleanup build packages ****" && \ + apk del --purge \ + build-dependencies && \ + rm -rf \ + /tmp/* \ + $HOME/.cache \ + $HOME/.composer + +# The linuxserver.io base image handles nginx config and service startup. +# It's pre-configured to serve a PHP application from /app/www/public. +# It also handles the PUID/PGID logic for permissions on /config volume. +# So, we don't need to copy nginx configs or write startup scripts. + +# Expose standard web ports +EXPOSE 80 443 + +# Define the volume for persistent data +VOLUME /config diff --git a/README.md b/README.md index 3c2f7d0e..4851d3da 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,28 @@ 对于有一定技术基础的用户,我们推荐使用 Docker 进行安装。这是最快、最稳定的方式。 -→ [查看 Docker 安装指南](https://hub.docker.com/r/linuxserver/grocy) +我们的 Docker 镜像基于本项目的源代码构建,默认使用中文界面,并已为您准备好一切。 + +1. **拉取镜像** + ```bash + docker pull nishizhen/anticlockwisegrocy:latest + ``` + +2. **运行容器** + ```bash + docker run -d \ + --name=anticlockwisegrocy \ + -p 9283:80 \ + -v /path/to/your/data:/config \ + nishizhen/anticlockwisegrocy:latest + ``` + **请注意**: + * `-p 9283:80`:将容器的 80 端口映射到您服务器的 9283 端口。您可以根据需要更改 `9283`。 + * `-v /path/to/your/data:/config`:将您的数据持久化存储在本地。请务必将 `/path/to/your/data` 替换为您服务器上的一个**真实路径**,例如 `/home/user/grocy_data`。 + +3. **访问应用** + 打开浏览器,访问 `http://<您的服务器IP>:9283`。 + 默认登录用户为 `admin`,密码为 `admin`,请在登录后立即修改密码。 ### 方式二:手动安装 From 46fda6922ea46f875b791a22eb08c924640f282a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:25:41 +0000 Subject: [PATCH 2/3] feat: Implement versioned Docker tagging This change updates the GitHub Actions workflow to implement a versioned Docker tagging strategy, as requested. - The workflow now reads the version from `version.json`. - It generates semantic version tags (e.g., `v4.5.0`, `v4.5`, `v4`) for the Docker image, in addition to the `latest` tag. - This makes the image tagging consistent with the practices of `linuxserver/grocy`. --- .github/workflows/docker-publish.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cb760b9a..3b91617c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -18,11 +18,20 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Get version + id: version + run: echo "tag=$(jq -r .Version < version.json)" >> $GITHUB_OUTPUT + - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v4 with: images: nishizhen/anticlockwisegrocy + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern={{version}},value=v${{ steps.version.outputs.tag }} + type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.tag }} + type=semver,pattern={{major}},value=v${{ steps.version.outputs.tag }} - name: Build and push Docker image uses: docker/build-push-action@v4 From d4e7e0b3c0d6c369781be1d3ddf1045f4fcc9af1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:30:19 +0000 Subject: [PATCH 3/3] feat: Build from source with versioned Docker tagging This change introduces a comprehensive Docker build process and a GitHub Actions workflow to publish versioned images to Docker Hub. - A new `Dockerfile` builds the application from the local source code, ensuring any project modifications are included in the image. The build process is modeled after the `linuxserver/grocy` image for consistency. - The Docker image is configured to use Chinese (`zh_CN`) as the default language. - The GitHub Actions workflow in `.github/workflows/docker-publish.yml` is configured to: - Build and push the image automatically on pushes to the `master` branch. - Read the application version from `version.json`. - Generate semantic version tags for the Docker image (e.g., `latest`, `v4.5.0`, `v4.5`, `v4`). - The `README.md` has been updated with instructions for using the new custom-built Docker image.