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

ci: Added dependabot, build, docker and deploy #1

Merged
merged 2 commits into from
Oct 31, 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
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
40 changes: 40 additions & 0 deletions .github/workflows/dockerci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Docker CI

on:
push:
branches: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permission:
contents: read
packages: read

steps:
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- uses: docker/metadata-action@v4
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- uses: docker/build-push-action@v5
env:
API_URL: 'http://example.org'
PUBLIC_API_URL: 'http://example.org'
with:
context: .
file: ./docker/Dockerfile
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
platforms: |-
linux/amd64
linux/arm64
61 changes: 61 additions & 0 deletions .github/workflows/dockerflycd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Docker Fly CD

on:
push:
tags: ['v*.*.*']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permission:
contents: read
packages: write

steps:
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3

- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: docker/metadata-action@v4
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- uses: docker/build-push-action@v5
env:
API_URL: ${{ secrets.API_URL }}
PUBLIC_API_URL: ${{ secrets.PUBLIC_API_URL }}
with:
context: .
file: ./docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: |-
linux/amd64
linux/arm64

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@v2

- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/testingci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Testing CI

on:
pull_request:
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'npm'
- run: npm ci
- run: npm run build
env:
API_URL: 'http://example.org'
PUBLIC_API_URL: 'http://example.org'
12 changes: 9 additions & 3 deletions Dockerfile → docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.16.0
ARG PORT=8080
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="NodeJS"
Expand All @@ -11,7 +12,7 @@ WORKDIR /app

# Set production environment
ENV NODE_ENV=production

ENV PORT="${PORT}"

# Throw-away build stage to reduce size of final image
FROM base as build
Expand All @@ -21,8 +22,8 @@ RUN apt-get update -qq && \
apt-get install -y python-is-python3 pkg-config build-essential

# Install node modules
COPY --link package.json package-lock.json .
RUN npm install --production=false
COPY --link package.json package-lock.json ./
RUN npm ci --include=dev

# Copy application code
COPY --link . .
Expand All @@ -40,5 +41,10 @@ FROM base
# Copy built application
COPY --from=build /app /app

# Expose port
EXPOSE ${PORT}

# Start the server by default, this can be overwritten at runtime
CMD [ "npm", "run", "start" ]

LABEL org.opencontainers.image.source="https://github.com/tminaorg/prednjica"
4 changes: 1 addition & 3 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ app = "prednjica"
primary_region = "cdg"

[build]

[env]
PORT = "8080"
image = "ghcr.io/tminaorg/prednjica:latest"

[http_service]
internal_port = 8080
Expand Down