-
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.
Merge pull request #89 from TIHLDE/devops(dockerfile)/dev
Dockerized and added deployment workflow
- Loading branch information
Showing
9 changed files
with
125 additions
and
14 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,15 @@ | ||
.github | ||
.next | ||
.vscode | ||
node_modules | ||
.dockerignore | ||
.env | ||
.env.example | ||
.eslintrc.cjs | ||
.gitignore | ||
docker-compose.yml | ||
Dockerfile | ||
Makefile | ||
next-env.d.ts | ||
prettier.config.js | ||
README.md |
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,51 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
|
||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: deployment_lock | ||
cancel-in-progress: false | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up SSH key | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "${{ secrets.KEY }}" > ~/.ssh/key | ||
chmod 600 ~/.ssh/key | ||
ssh-keyscan ${{ secrets.HOST }} >> ~/.ssh/known_hosts | ||
- name: Create .env file | ||
run: | | ||
echo 'DATABASE_URL="${{ secrets.DATABASE_URL }}"' >> .env | ||
echo 'NEXTAUTH_URL="${{ secrets.NEXTAUTH_URL }}"' >> .env | ||
echo 'NEXT_PUBLIC_LEPTON_API_URL="${{ secrets.NEXT_PUBLIC_LEPTON_API_URL }}"' >> .env | ||
echo 'ALLOWED_GROUP_SLUGS="${{ secrets.ALLOWED_GROUP_SLUGS }}"' >> .env | ||
echo 'NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}"' >> .env | ||
- name: Copy .env to OpenStack server | ||
run: | | ||
scp -v -i ~/.ssh/key .env ${{ secrets.USER }}@${{ secrets.HOST }}:${{ secrets.PATH }} | ||
- name: Deploy to OpenStack server | ||
run: | | ||
ssh -v -i ~/.ssh/key ${{ secrets.USER }}@${{ secrets.HOST }} << 'ENDSSH' | ||
cd ${{ secrets.PATH }} | ||
chmod 0600 .env | ||
git pull | ||
make prod | ||
ENDSSH |
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,36 @@ | ||
FROM node:current-alpine AS build | ||
|
||
RUN apk add openssl | ||
|
||
WORKDIR /build | ||
|
||
COPY . . | ||
|
||
RUN npm install -g pnpm | ||
|
||
RUN pnpm i --frozen-lockfile | ||
|
||
ENV SKIP_ENV_VALIDATION=1 | ||
|
||
RUN pnpm build | ||
|
||
FROM node:current-alpine AS runner | ||
|
||
WORKDIR /app | ||
|
||
RUN apk add openssl | ||
# Prisma is used in prod deployment | ||
RUN npm install -g prisma | ||
|
||
COPY --from=build /build/.next/standalone ./ | ||
RUN rm -f .env | ||
COPY --from=build /build/.next/static ./.next/static/ | ||
COPY --from=build /build/prisma ./prisma/ | ||
COPY --from=build /build/public ./public/ | ||
|
||
EXPOSE 3000 | ||
ENV PORT=3000 | ||
|
||
ENV NEXT_TELEMETRY_DISABLED=1 | ||
|
||
CMD [ "node", "server.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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
.PHONY: db | ||
db: | ||
docker compose up -d | ||
|
||
.PHONY: prod | ||
prod: | ||
docker build -t blitzed:latest . | ||
docker container stop blitzed | ||
docker container rm blitzed | ||
- prisma migrate deploy | ||
docker run --env-file .env -p 4000:3000 --name blitzed -d blitzed:latest |
File renamed without changes.
Empty file.
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
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