diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..40afce8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git/ +Dockerfile +.vscode/ \ No newline at end of file diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml new file mode 100644 index 0000000..17cf049 --- /dev/null +++ b/.github/workflows/build-docker.yaml @@ -0,0 +1,47 @@ +name: build-docker +on: push + +jobs: + build: + name: Build Image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + - id: short-sha + uses: benjlevesque/short-sha@v1.2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/netbymatt/ws4kp + tags: | + type=raw,priority=1000,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=ref,event=branch + ${{ steps.short-sha.outputs.sha }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up 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 and Push + id: docker_build + uses: docker/build-push-action@v3 + with: + context: . + pull: true + push: ${{ github.ref == 'refs/heads/main' }} + platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0ca4098 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM node:18-alpine +WORKDIR /app + +COPY package*.json . +RUN npm ci + +COPY . . +CMD ["node", "index.js"] \ No newline at end of file diff --git a/README.md b/README.md index 659f69a..7312c73 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,18 @@ This project is based on the work of [Mike Battaglia](https://github.com/vbguyny ## Run Your WeatherStar There are a lot of CORS considerations and issues with api.weather.gov that are easiest to deal with by running a local server to see this in action (or use the live link above). You'll need Node.js >12.0 to run the local server. +To run via Node locally: ``` git clone https://github.com/netbymatt/ws4kp.git cd ws4kp npm i node index.js ``` + +To run via Docker: +``` +docker run -p 8080:8080 ghcr.io/netbymatt/ws4kp +``` Open your web browser: http://localhost:8080/ ## Updates in 5.0