This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create docker images for standalone use (#793)
- Loading branch information
Showing
8 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.git/ | ||
.github/ | ||
.gitignore | ||
docker/Dockerfile* | ||
docker/README.md | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 \ | ||
. | ||
``` |