Skip to content

Commit dd52d06

Browse files
committed
update docker-env and add cd
1 parent aedb632 commit dd52d06

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

.docker/Dockerfile.prod

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM node:alpine AS deps
2+
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
3+
RUN apk add --no-cache libc6-compat
4+
WORKDIR /app
5+
COPY package.json yarn.lock ./
6+
RUN yarn install --frozen-lockfile
7+
8+
# Rebuild the source code only when needed
9+
FROM node:alpine AS builder
10+
ENV NODE_ENV production
11+
WORKDIR /app
12+
COPY . .
13+
COPY --from=deps /app/node_modules ./node_modules
14+
RUN yarn build
15+
16+
FROM gcr.io/distroless/nodejs
17+
WORKDIR /app
18+
ENV NODE_ENV production
19+
# You only need to copy next.config.js if you are NOT using the default configuration
20+
COPY --from=builder /app/next.config.js ./
21+
COPY --from=builder /app/public ./public
22+
COPY --from=builder /app/.next ./.next
23+
COPY --from=builder /app/node_modules ./node_modules
24+
COPY --from=builder /app/server.js ./server.js
25+
26+
EXPOSE 3000
27+
28+
CMD ["server.js" ]
29+
30+
31+
# https://nextjs.org/docs/deployment#docker-image
32+
# https://github.com/GoogleContainerTools/distroless#docker

.docker/docker-compose.dev.yml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ services:
1212
- ../src:/app/src
1313
- ../styles:/app/styles
1414
- ../utils:/app/utils
15+
environment:
16+
- TZ=Asia/Tokyo
1517
ports:
1618
- 3000:3000
1719
networks:
@@ -40,6 +42,7 @@ services:
4042
- DB_PORT=3306
4143
- DB_ROOT_PASSWORD=testpass
4244
- GOOGLE_APPLICATION_CREDENTIALS=firebaseCredentials.json
45+
- TZ=Asia/Tokyo
4346
volumes:
4447
- ../firebaseCredentials.json:/firebaseCredentials.json
4548
ports:

.github/workflows/cd.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
gcr-push:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v2
14+
- name: GCP Authenticate
15+
uses: google-github-actions/setup-gcloud@master
16+
with:
17+
project_id: ${{ secrets.GCP_PROJECT_ID }}
18+
service_account_key: ${{ secrets.GCP_SA_KEY }}
19+
export_default_credentials: true
20+
- name: Configure docker
21+
run: gcloud auth configure-docker --quiet
22+
- name: Build
23+
run: docker build -t asia.gcr.io/${{ secrets.GCP_PROJECT_ID }}/frontend:$GITHUB_SHA -t asia.gcr.io/${{ secrets.GCP_PROJECT_ID }}/frontend:latest -f ./.docker/Dockerfile.prod .
24+
- name: Push
25+
run: docker push asia.gcr.io/${{ secrets.GCP_PROJECT_ID }}/frontend --all-tags

0 commit comments

Comments
 (0)