-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: create container image and publish to docker hub and github re…
…gistry (#337)
- Loading branch information
Showing
5 changed files
with
127 additions
and
8 deletions.
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,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 |
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,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 }} |
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 |
---|---|---|
@@ -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 |
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,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 |