Skip to content

Commit

Permalink
Fixes for Nairobinet + General Improvements (#14)
Browse files Browse the repository at this point in the history
* Add .dockerignore

* Fail npm build cmd on error

* update some pkgs

* Improve Dockerfile

* Cache docker in ci

* Add set -e

* RUN chown -R node:node build

* WIP dockerfile

* Working Dockerfile
  • Loading branch information
harryttd authored Apr 21, 2023
1 parent 3caf629 commit dff8aa5
Show file tree
Hide file tree
Showing 6 changed files with 2,242 additions and 290 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github
build
craco.config.ts
Dockerfile
LICENSE.md
node_modules
README.md
74 changes: 49 additions & 25 deletions .github/workflows/build_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,54 @@ on:
jobs:
publish-to-ghcr:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Login to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository_owner }}/tezos-faucet
tags: |
type=ref,event=branch
type=ref,event=pr
type=match,pattern=v(.*),group=1
- name: Push container to GHCR
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: Dockerfile
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: "true"

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

- name: Login to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/${{ github.repository_owner }}/tezos-faucet
tags: |
type=ref,event=branch
type=ref,event=pr
type=match,pattern=v(.*),group=1
- name: Push container to GHCR
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
context: .
file: Dockerfile
labels: ${{ steps.meta.outputs.labels }}
push: true
tags: ${{ steps.meta.outputs.tags }}

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
15 changes: 6 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

COPY package.json ./
COPY package-lock.json ./
COPY src ./src
COPY scripts ./scripts
COPY public ./public
COPY tsconfig.json ./tsconfig.json
RUN chown node:node /app

RUN npm install --silent
RUN npm run build
USER node

COPY --chown=node:node . ./

RUN npm install

COPY entrypoint.sh ./entrypoint.sh
CMD ["sh", "-c", "/app/entrypoint.sh" ]
3 changes: 2 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh

set -e
# We need to buid because the configuration file may be modified at runtime.
npm run build

serve -s build -p 80
Loading

0 comments on commit dff8aa5

Please sign in to comment.