Skip to content

Commit

Permalink
Merge pull request #9 from SimplyEdit/add/multi-platform-build
Browse files Browse the repository at this point in the history
Change Docker workflow to use buildx
  • Loading branch information
Potherca authored Jul 12, 2023
2 parents 46e6d75 + 1724c41 commit 8e70f4d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ jobs:
| tr --complement --squeeze-repeats '[:alnum:]._-' '_')" \
>> "${GITHUB_ENV}"
- uses: actions/checkout@v3

- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker Image
run: |
docker build \
--tag "ghcr.io/simplyedit/simplycode-docker:${{ env.TAG }}" \
.
docker push "ghcr.io/simplyedit/simplycode-docker:${{ env.TAG }}"
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: "ghcr.io/simplyedit/simplycode-docker:${{ env.TAG }}"
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ docker run \

This will mount the current working directory into the docker image at the right place, and start the SimplyCode server.

When using Docker Desktop, it is advised to use the `--publish-all` flag to make the SimplyCode server available on the host machine.

That way, the SimplyCode server can be accessed by using the "Open in Browser" button in Docker Desktop.

![img.png][1]

## Contribute

Feedback and contributions are welcome. Please open an issue or pull request.
Expand All @@ -66,3 +72,5 @@ Created by [SimplyEdit](https://simplyedit.io) under an MIT License.
[project-stage-page]: https://blog.pother.ca/project-stages/
[standard-readme-link]: https://github.com/RichardLitt/standard-readme
[standard-readme-shield]: https://img.shields.io/badge/-Standard%20Readme-brightgreen.svg

[1]: data:image/png;base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n1EjP55Ji0vNl23PB4QRXtoLfsO6yHSDluFYiuxG56tSuOxupToTAdHYHk8/Uq0fzKW+xVbLC+arZ/FVdiorqKr+yC6reXabKGs77+OosogL1q2mn7wyypSJL+tz/GgabPxWqrUj48v1XYqx3+S6EwHR2B5EYqMuuX6uhDr0bOztxgp9dyrQLrF+lm0DU1a7k1ttNx3LwpR9L/QTrsdXYwx3kaLddW6F3dn5SY5j8Os+uGz88tiH4vSeBIvJTrTwRFYHqOLsslyO6bRzpZYbq919TmW62s98Y2W+918FJJs63+svJrqiW/ZW26dsV3WOrK8vr86zHxT9fpW6i8gWxGd6eAILI82K/HkbTrNRrvl1nj9LK6mNuott853WK4tF97H8VO0EE2K7WjNP/3loZptjRtFC57igNSPjy/ddKmpE53p4AgsX02d0cmFUbiCdstXLvGtnMXV1Ea95Vbh4/V9jIGWTzo92du40Mae4H3VJX6LkW7LN0WrOtGZDo7Dcj1AltgVfxpRuIKtLLetVM7iamqjheWrzy70caB6Csu12WLTRf/jONdGLGQWf3oerjPmOBqLBvUg2GGxke/bqRyforQjnEdnOjgOyxU9MfozaUwUrkBt8z++cmG5NVg5i1anbrnaNtnnoo7vW9xuYfmm6Oh3MzaiqHA+TGhrsX5x0IrI4k9KrBDHQLyw1InOdHBMlsNzSHSmAyyHgyY60wGWw0ETnekAy+Ggic50gOVw0ERnOtiz5XyGHyqIHtGZDvZs+c1bX4v7BqCIHtGZDvZs+TXCOWxgVCC/dgiWX79xE9GhQJQQMaItfezfckWuTbgOq7XfoxIV41AsB1gOLIf8YDnkB8shPyeS6QPkhlgO+cFyyA+WQ36wHPKD5ZAfLIf8YDnkB8shP1gO+cFyyA+WQ36wHPKD5ZCf/wMVbF7BowpW/wAAAABJRU5ErkJggg==
35 changes: 29 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ EOF
}

defaultCommand() {
groupmod --gid "${USER_GID}" 'www-data'
usermod --gid "${USER_GID}" --uid "${USER_ID}" 'www-data'
groupmod --gid "${USER_GID}" 'www-data' || true
usermod --gid "${USER_GID}" --uid "${USER_ID}" 'www-data' || true

apache2-foreground
}
Expand All @@ -68,6 +68,31 @@ entrypoint() {
fi
}

guessUrl(){
local hasHost isSetFromFile url

hasHost="$(getent 'hosts' 'host.docker.internal' | awk '{ print $1 }')"
isSetFromFile="$(grep 'docker.internal' /etc/hosts | awk '{ print $1 }')"

# host.docker.internal is not available on Linux, it is set in /etc/hosts
# If `host.docker.internal` is available and not set in /etc/hosts,
# we are in Docker Desktop for Mac or Windows.
# If it is not available, or is available but set in /etc/hosts, we are on
# Linux.

if [ "${hasHost}" == 'host.docker.internal' ] && [ "${isSetFromFile}" != 'host.docker.internal' ]; then
# we are on Docker Desktop for Mac or Windows
url='Docker Desktop'
else
# we are on Linux
url="https://$(tail -n1 /etc/hosts | cut -f1)"
if [ ! -f '/var/www/www/api/data/generated.html' ]; then
url="${url}/simplycode/"
fi
fi

echo "${url}"
}
runChecks() {
local pass=true
local url
Expand All @@ -86,10 +111,8 @@ runChecks() {
find /var/www/www/api/data -maxdepth 1 -type d -exec echo -e "\t{}/" \;
find /var/www/www/api/data -maxdepth 1 -type f -exec echo -e "\t{}" \;

url="https://$(tail -n1 /etc/hosts | cut -f1)"
if [ ! -f '/var/www/www/api/data/generated.html' ]; then
url="${url}/simplycode/"
fi
url="$(guessUrl)"
readonly url

echo -e "Running on $(tput setaf 7)${url}$(tput sgr 0)\n"
fi
Expand Down

0 comments on commit 8e70f4d

Please sign in to comment.