Skip to content

Commit

Permalink
build: create container image and publish to docker hub and github re…
Browse files Browse the repository at this point in the history
…gistry (#337)
  • Loading branch information
groupsky authored Feb 14, 2022
1 parent 36996b3 commit 0d8aaca
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 8 deletions.
22 changes: 22 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.codeclimate.yml
.dockerignore
.editorconfig
.env
.gitignore
.github
.idea
cypress*
Dockerfile
example.env
log
netlify.toml
node_modules
npm-debug.log
pids
public/*_stats.json
public/css/main.css*
public/fonts/font-awesome
public/fonts/glyphicons
public/js/scripts.js
public/sw.js
public/views
13 changes: 9 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@

version: 2
updates:
- package-ecosystem: "npm"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
interval: "monthly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
interval: "monthly"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
57 changes: 57 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish Docker image

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'
release:
types: [published]

jobs:
container:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: |
bspborg/smartbirds-web
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.env
.idea/
node_modules/
bower_components/
public/js/scripts.js
npm-debug.log
log/
pids/
public/css/main.css*
uploads/

public/*_stats.json
public/css/main.css*
public/js/scripts.js
public/sw.js
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#### Stage BUILD ########################################################################################################
FROM node:16.13.1-alpine3.15 AS build

# Install tools, create app dir, add user and set rights
RUN set -ex && \
mkdir -p /app

# Set work directory
WORKDIR /app

# copy package.json and lock file
COPY package*.json ./

# Install Build tools
RUN npm ci --no-update-notifier --only=production

# Copy sources
COPY . .

# Build static
RUN npm run build && \
npm run build:fonts && \
npm run build:views

#### Stage RELEASE #####################################################################################################
FROM nginx:1.21.5-alpine AS RELEASE

# copy generated static site
COPY --from=build /app/public /usr/share/nginx/html

# make readonly to nginx
RUN chown -R root:nginx /usr/share/nginx/html && \
chmod -R go-w /usr/share/nginx/html

EXPOSE 80

0 comments on commit 0d8aaca

Please sign in to comment.