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

Add github action #23

Merged
merged 7 commits into from
Nov 8, 2023
Merged
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
121 changes: 121 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Build

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
push:
branches: [ "master" ]

env:
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
build-image-visualization:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/visualization
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image (visualization)
uses: docker/build-push-action@v5
with:
context: ./visualization
#file: ./visualization/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build-image-fluentd:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/fluentd
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image (fluentd)
uses: docker/build-push-action@v5
with:
context: ./fluentd
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build-image-grafana:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/grafana
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image (grafana)
uses: docker/build-push-action@v5
with:
context: ./grafana
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BUILDKIT_DOCKER_BUILD = DOCKER_BUILDKIT=1 docker build
SINDAN_FLUENTD_TAG = ghcr.io/sindan/sindan-docker/fluentd:v1.6-1-rev2
SINDAN_VISUALIZATION_TAG = ghcr.io/sindan/sindan-docker/visualization:2.6.3-alpine-rev3
SINDAN_GRAFANA_TAG = ghcr.io/sindan/sindan-docker/grafana:6.5.0-rev1
SINDAN_FLUENTD_TAG = ghcr.io/sindan/sindan-docker/fluentd:latest
SINDAN_VISUALIZATION_TAG = ghcr.io/sindan/sindan-docker/visualization:latest
SINDAN_GRAFANA_TAG = ghcr.io/sindan/sindan-docker/grafana:latest
SINDAN_ENVOY_TAG = ghcr.io/sindan/sindan-docker/envoy:latest
SINDAN_CERTBOT_NGINX_TAG = ghcr.io/sindan/sindan-docker/certbot-nginx:latest
TLS_HOSTNAME = sindan.sindan-net.com
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ $ cp .secrets/rails_secret_key_base.txt.example .secrets/rails_secret_key_base.t
$ make build init
```

Instead of building locally, you can download pre-built images from [DockerHub](https://hub.docker.com/u/sindan).
Instead of building locally, you can download pre-built images from [GitHub Packages](https://github.com/orgs/SINDAN/packages?repo_name=sindan-docker).
Note that in this case, you must not edit `rails_secret_key_base.txt` as you like.
Just follow the next:

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ services:
- "80:80"

fluentd:
image: ghcr.io/sindan/sindan-docker/fluentd:v1.6-1-rev2
image: ghcr.io/sindan/sindan-docker/fluentd:latest
build:
context: ./fluentd
hostname: sindan-fluentd
Expand Down Expand Up @@ -122,7 +122,7 @@ services:
com.sindan-net.sindan-mysql.description: "Storing diagnosis logs for sindan-visualization"

visualization:
image: ghcr.io/sindan/sindan-docker/visualization:3.1.2-alpine-rev1
image: ghcr.io/sindan/sindan-docker/visualization:latest
build:
context: ./visualization
target: production
Expand Down Expand Up @@ -161,7 +161,7 @@ services:
com.sindan-net.sindan-visualization.description: "Web frontend to manage diagnosis logs"

grafana:
image: ghcr.io/sindan/sindan-docker/grafana:6.5.0-rev1
image: ghcr.io/sindan/sindan-docker/grafana:latest
build:
context: ./grafana
hostname: sindan-grafana
Expand Down
17 changes: 7 additions & 10 deletions visualization/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ ENV RAILS_ENV=production
WORKDIR /app

COPY sindan-visualization/. .
COPY database.yml config
COPY secrets.yml config
COPY database.dummy.yml config/database.yml
COPY seeds.rb db
COPY bundle-install.sh .

Expand All @@ -35,16 +34,14 @@ RUN apk add --no-cache --update \
shadow \
sudo \
tzdata \
yarn \
&& gem install bundler --no-document \
&& bundle config build.nokogiri --use-system-libraries \
&& bash bundle-install.sh \
&& yarn install
yarn
RUN bash bundle-install.sh
RUN yarn install

# hadolint ignore=SC2215
RUN --mount=type=secret,id=rails_secret_key_base,target=/run/secrets/rails_secret_key_base,required \
--mount=type=secret,id=db_password,target=/run/secrets/db_password,required \
bundle exec rails assets:precompile
RUN --mount=type=secret,id=rails_secret_key_base,target=/run/secrets/rails_secret_key_base \
--mount=type=secret,id=db_password,target=/run/secrets/db_password
RUN SECRET_KEY_BASE=DUMMY bundle exec rails assets:precompile

FROM ruby:3.2.2-alpine as production
LABEL maintainer "mi2428 <[email protected]>"
Expand Down
12 changes: 12 additions & 0 deletions visualization/database.dummy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
default: &default
adapter: mysql2
encoding: utf8
pool: 5
host: <%= ENV['DB_HOST'] %>
port: 3306

production:
<<: *default
database: <%= ENV['DB_NAME'] %>
username: <%= ENV['DB_GRANTED_USER'] %>
password: ''