Skip to content

Commit

Permalink
Update: docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed May 22, 2020
1 parent cc0b73d commit d0d1405
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.circleci
.github
.git

node_modules

.DS_Store
/dist

.env.local
.env.*.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: release

on:
push:
tags:
- v*.*.*
branches-ignore:
- '**'

env:
IMAGE_NAME: traq-widget

jobs:
image:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Set IMAGE_TAG env
run: echo ::set-env name=IMAGE_TAG::$(echo ${GITHUB_REF:11})
- uses: actions/checkout@v2
- name: Login GitHub Registry
run: docker login docker.pkg.github.com -u traPtitech -p ${{ secrets.GITHUB_TOKEN }}
- name: Build Image
run: docker build -t docker.pkg.github.com/traptitech/traQ_Widget/${IMAGE_NAME}:${IMAGE_TAG} .
- name: Push image to GitHub Registry
run: docker push docker.pkg.github.com/traptitech/traQ_Widget/${IMAGE_NAME}:${IMAGE_TAG}
- name: Push image to GitHub Registry (latest)
run: |
docker tag docker.pkg.github.com/traptitech/traQ_Widget/${IMAGE_NAME}:$IMAGE_TAG docker.pkg.github.com/traptitech/traQ_Widget/${IMAGE_NAME}:latest
docker push docker.pkg.github.com/traptitech/traQ_Widget/${IMAGE_NAME}:latest
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# alpineにするとnode-gypで死ぬ
FROM node:14.3.0 as build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build


FROM caddy:2.0.0-alpine
EXPOSE 80
COPY build/Caddyfile /etc/caddy/Caddyfile
COPY --from=build /app/dist /usr/share/caddy
46 changes: 46 additions & 0 deletions build/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
admin off
}

:80

encode zstd gzip

file_server
root * /usr/share/caddy

@brotli {
file {
try_files {path}.br
}
header Accept-Encoding *br*
}
handle @brotli {
header Content-Encoding br
rewrite {http.matchers.file.relative}
}

@svg {
file
path *.svg
}
@css {
file
path *.css
}
@js {
file
path *.js
}
@html {
file
path *.html
}
@htmlpath {
path_regexp ^[^.]*$
}
header @svg Content-Type image/svg+xml
header @css Content-Type text/css
header @js Content-Type text/javascript
header @html Content-Type text/html
header @htmlpath Content-Type text/html

0 comments on commit d0d1405

Please sign in to comment.