Skip to content

Commit

Permalink
Merge pull request #48 from UoaWDCC/deploy
Browse files Browse the repository at this point in the history
added dockerfiles to github actions
  • Loading branch information
alexwillmcleod authored Feb 4, 2024
2 parents b6d8728 + af3d0aa commit 962380c
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config strapi/fly.production.toml
- run: flyctl deploy --remote-only --config strapi/fly.production.toml --dockerfile strapi/Dockerfile.production
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STRAPI }}
deploy-frontend:
Expand All @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config frontend/fly.production.toml
- run: flyctl deploy --remote-only --config frontend/fly.production.toml --dockerfile frontend/Dockerfile.production
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND }}
deploy-storage:
Expand All @@ -30,6 +30,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config storage/fly.production.toml
- run: flyctl deploy --remote-only --config storage/fly.production.toml --dockerfile storage/Dockerfile.production
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STORAGE }}
6 changes: 3 additions & 3 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config strapi/fly.staging.toml
- run: flyctl deploy --remote-only --config strapi/fly.staging.toml --dockerfile strapi/Dockerfile.staging
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STRAPI_STAGING }}
deploy-frontend:
Expand All @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config frontend/fly.staging.toml
- run: flyctl deploy --remote-only --config frontend/fly.staging.toml --dockerfile frontend/Dockerfile.staging
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_FRONTEND_STAGING }}
deploy-storage:
Expand All @@ -30,6 +30,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only --config storage/fly.staging.toml
- run: flyctl deploy --remote-only --config storage/fly.staging.toml --dockerfile storage/Dockerfile.staging
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_STORAGE_STAGING }}
File renamed without changes.
49 changes: 49 additions & 0 deletions frontend/Dockerfile.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# syntax = docker/dockerfile:1

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

LABEL fly_launch_runtime="Next.js"

# Next.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"

# Install pnpm
ARG PNPM_VERSION=8.3.1
RUN npm install -g pnpm@$PNPM_VERSION


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link .npmrc package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod=false

# Copy application code
COPY --link . .

# Build application
RUN pnpm run build

# Remove development dependencies
RUN pnpm prune --prod


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "pnpm", "run", "start" ]
35 changes: 35 additions & 0 deletions strapi/Dockerfile.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link .npmrc package.json yarn.lock ./
RUN yarn install --frozen-lockfile --prod=false

# Copy application code
COPY --link . .

# Build application
RUN yarn run build

# Remove development dependencies
# RUN yarn prune --prod

# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Setup sqlite3 on a separate volume
RUN mkdir -p /data
VOLUME /data

# Start the server by default, this can be overwritten at runtime
EXPOSE 1337
CMD [ "yarn", "run", "start" ]
File renamed without changes.

0 comments on commit 962380c

Please sign in to comment.