Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build container with github actions #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules/
/dist/

52 changes: 52 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: build and push docker container

on:
push:
branches:
- master
- gh-actions

jobs:
build-and-push:
runs-on: ubuntu-latest

strategy:
matrix:
include:
- target: x86
docker-image: cbase/infoscreens
compose-file: docker-compose.yml
docker-file: Dockerfile
# - target: raspberrypi3
# docker-image: cbase/raspberrypi3-infoscreens
# compose-file: docker-compose-raspberrypi3.yml
# docker-file: Dockerfile-raspberrypi3

steps:
- name: checkout
uses: actions/checkout@v2

- name: set up qemu
uses: docker/setup-qemu-action@v1

- name: set up docker buildx
uses: docker/setup-buildx-action@v1

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

- name: build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ${{ matrix.docker-file }}
push: true
platforms: linux/amd64,linux/arm
tags: |
${{ matrix.docker-image }}:latest
${{ matrix.docker-image }}:${{ github.sha }}

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/node_modules/
/dist/
npm-debug.log
package-lock.json

29 changes: 19 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
FROM node:10-alpine
FROM node:16-alpine AS builder

# Reduce npm install verbosity, overflows Travis CI log view
ENV NPM_CONFIG_LOGLEVEL warn
ENV NODE_ENV production
WORKDIR /var/infoscreens

EXPOSE 8080
COPY package.json package-lock.json ./
RUN npm ci

COPY . ./
RUN npm run build

FROM node:16-alpine

ENV NODE_ENV production

RUN mkdir -p /var/infoscreens
WORKDIR /var/infoscreens
COPY package.json /var/infoscreens
COPY server /var/infoscreens/server
COPY dist /var/infoscreens/dist

# Install NoFlo and dependencies
RUN npm install --only=production
COPY package.json package-lock.json ./
RUN npm ci --only=production

COPY server /var/infoscreens/server
COPY --from=builder /var/infoscreens/dist /var/infoscreens/dist

# Map the volumes
VOLUME /var/infoscreens/dist
VOLUME /var/infoscreens/videos
VOLUME /var/infoscreens/pictures

EXPOSE 8080

CMD npm start

Loading