AWS Amplify & Tina Grande

Hey everyone - thank you in advance for your time and consideration.

I’m attempting to deploy a working TinaGrande project using AWS Amplify and I’m running into some challenges. First, I’m trying to use the environmental variables that are mentioned in articles about deploying to Gatsby Cloud (closest comp I could find) but can’t seem to trigger a GitHub repo push (which works out of the box locally). Second, the editing is not working either - triggering a too many redirects to index error which I imagine is simply the actual save not working.

Part of me thinks I won’t be able to deploy to Amplify but I figure I’d give you all a shout before abandoning this approach.

If Amplify doesn’t work are there any other solutions for a hosted deployment that would allow my partners to make edits securely online? I’ve spent a lot of time going through docs and looking for articles so forgive me if I’m missing anything obvious.

Thank you

  • Stefan
1 Like

Stefan,

I’ve gotten it up and working on Heroku with basic auth to protect the site. Here are the steps I had to go through:

  1. Dockerize my gatsby project. Here’s my Dockerfile

FROM node:alpine

EXPOSE 8000

RUN apk update && apk add ca-certificates yarn git openssh-client util-linux

RUN yarn global add gatsby-cli

WORKDIR /app

COPY ./package.json .

RUN yarn install && yarn cache clean

RUN gatsby clean

COPY . .

CMD [“yarn”, “develop”, “-H”, “0.0.0.0” ]

  1. Add a .dockerignore file

./node_modules
./cache
./public
.env*

  1. Add basic auth to my gatsby app. You probably want to disable this in production.

yarn add express-basic-auth

  1. In gatsby-node.js

const basicAuth = require(“express-basic-auth”)
require(“dotenv”).config({
path: .env.${process.env.NODE_ENV},
})

exports.onCreateDevServer = ({ app }) => {
const users = {}
// Add environment users
users[process.env.BASIC_AUTH_USER] = process.env.BASIC_AUTH_PWD

app.use(
basicAuth({
users: users,
challenge: true,
realm: “website-content”,
})
)
}

  1. Create your Heroku app (https://devcenter.heroku.com/articles/container-registry-and-runtime)
  2. Add environment variables:
    1. BASIC_AUTH_USER
    2. BASIC_AUTH_PWD
    3. SSH_KEY
    4. TINA_CEE

Let me know if you have any issues.

1 Like

Just found an issue with this approach. The free version of Heroku spins down the container, so when a new version is spun up, it doesn’t have the latest version of the git repo, so when you try to save, you get an error about Updates were rejected.

Is there a way through the plugin to issue a git pull to update the local git repo?

1 Like

Apologies for the delay in response. I had to shift gears after hitting a wall on this project.

I went ahead and just deployed on Gatsby Cloud - much easier… though extremely sub-optimal on a number of levels - not being able to set env vars at the branch level is kind of rough to start… and since I’ve already got a ton of intellectual equity in AWS it’s not like GC’s going to replace anything else so it just requires me to manage multiple environments… which really sucks when carrying a deep, diverse load of projects.

Anyways… excuse my griping… GC works for now. We’ll see how things go if/when I get to domain names.

I also have a Strapi/Gatsby project in parallel that uses ec2/Amplify and it’s pretty powerful… but Tina is an optimal interface for a certain kind of user so I’d love to get it figured out some day.

I will make a point of following up if I do.

thanks and cheers

  • S

No worries. I ended up moving away from Docker myself. The problem was that my docker container would get spun down, so when it came back up, it would only have the version of files it was built with.

I’m now using Caddy to front gatsby develop and it’s working well.