Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

Commit

Permalink
feat: create docker images for standalone use (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
chetan authored Nov 22, 2021
1 parent b8aaf2b commit 73a854e
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git/
.github/
.gitignore
docker/Dockerfile*
docker/README.md
node_modules/
1 change: 0 additions & 1 deletion .github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
name: Lint and Build
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v2

Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/on_tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@ jobs:
release_url: https://github.com/resoai/TileBoard/releases/tag/v${{ steps.get-version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.REPO_WORKFLOW_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Docker build
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 \
--pull \
-t tileboard/tileboard:latest \
-t tileboard/tileboard:${{ steps.get-version.outputs.version }} \
-f docker/Dockerfile.run \
--push \
.
8 changes: 8 additions & 0 deletions docker/00-check-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

NGINX_HOME=/usr/share/nginx/html

if [ ! -f $NGINX_HOME/config.js ]; then
echo "error: $NGINX_HOME/config.js not found"
exit 1
fi
21 changes: 21 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:16 AS builder

RUN mkdir -p /build
WORKDIR /build

COPY ./package.json yarn.lock /build/

RUN yarn install

COPY ./ /build

RUN yarn run build


# Runtime image
FROM nginx:alpine AS runtime

COPY ./docker/00-check-config.sh /docker-entrypoint.d/
COPY --from=builder /build/build /usr/share/nginx/html

RUN touch /usr/share/nginx/html/styles/custom.css
17 changes: 17 additions & 0 deletions docker/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:16 AS builder

RUN mkdir -p /build
WORKDIR /build

COPY ./package.json yarn.lock /build/

RUN yarn install

COPY ./ /build

RUN yarn run build


# Hack for easily copying built files
FROM scratch AS exporter
COPY --from=builder /build/build .
7 changes: 7 additions & 0 deletions docker/Dockerfile.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Runtime image
FROM nginx:alpine AS runtime

COPY ./docker/00-check-config.sh /docker-entrypoint.d/
COPY ./build /usr/share/nginx/html

RUN touch /usr/share/nginx/html/styles/custom.css
47 changes: 47 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Running with Docker

1. Download the [sample
config](https://raw.githubusercontent.com/resoai/TileBoard/master/config.example.js)
file to `config.js` and edit it.

```sh
wget -O config.js https://raw.githubusercontent.com/resoai/TileBoard/master/config.example.js
vim config.js
```

2. Copy the following to `docker-compose.yml`:

```yaml
version: '2'
services:
tileboard:
image: tileboard/tileboard:latest
restart: unless-stopped
ports:
- 9000:80
volumes:
- ./config.js:/usr/share/nginx/html/config.js
```

3. Run with `docker-compose up --detach`
4. Access at http://localhost:9000

## Building

```sh
docker build -t tileboard/tileboard -f docker/Dockerfile .
```

Multi-platform:

```sh
rm -rf ./build/
docker buildx build -t tileboard/tileboard:build -f docker/Dockerfile.build --output build .
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
--pull \
-t tileboard/tileboard:latest \
-f docker/Dockerfile.run \
--push \
.
```

0 comments on commit 73a854e

Please sign in to comment.