Browse Source

add Dockerfile and tweak deployment instructions

pull/1/head
Trent Larson 8 months ago
parent
commit
6cd4a5a988
  1. 6
      .env.sample
  2. 13
      Dockerfile
  3. 9
      README.md
  4. 1
      package.json
  5. 4
      server.js

6
.env.sample

@ -25,9 +25,9 @@ INFURA_PROJECT_ID=???
# default is https://test-image.timesafari.app # default is https://test-image.timesafari.app
#DOWNLOAD_IMAGE_SERVER=test-image.timesafari.app #DOWNLOAD_IMAGE_SERVER=test-image.timesafari.app
# default is 3000 # default is 3002
#PORT=3000 #PORT=3000
# default is jdbc:sqlite:./sqlite-db.sqlite # default is ./image.sqlite
# file name also referenced in flyway.conf and in code # file name also referenced in flyway.conf and in code
#SQLITE_FILE=./image-db.sqlite #SQLITE_FILE=./image.sqlite

13
Dockerfile

@ -0,0 +1,13 @@
# syntax=docker/dockerfile:1
FROM node:21-alpine
ARG IMAGE_API_VERSION
RUN npm install -g pnpm
RUN apk add git
RUN git clone https://gitea.anomalistdesign.com/log-trade/image-api.git
WORKDIR image-api
RUN git checkout $IMAGE_API_VERSION
RUN pnpm install --prod
CMD node server.js

9
README.md

@ -39,13 +39,16 @@ JWT=`node -e "$CODE"`; curl -X DELETE -H "Authorization: Bearer $JWT" http://loc
## deploy to prod first time ## deploy to prod first time
* Do the necessary steps from "setup" above. * Do the necessary steps from "setup" above, or `docker build` it.
* In object storage, set up bucket and erase any test data. * In object storage, set up bucket (and erase any test data).
* Create a cert for the image delivery & image API servers.
* In haproxy, set a permanent web forward to the correct storage location. * In haproxy, set a permanent web forward to the correct storage location.
* eg. `http-request redirect code 301 location https://a2-west.americancloud.com/images6618:giftsimagetest%[capture.req.uri] if { hdr_dom(host) -i test-image.timesafari.app }`
## deploy to prod subsequent times ## deploy to prod subsequent times
* Add CHANGELOG.md entry. Update version in server.js file. * Update version in server.js file. Add CHANGELOG.md entry.

1
package.json

@ -1,4 +1,5 @@
{ {
"name": "Images for Trade", "name": "Images for Trade",
"version": "0.0.1", "version": "0.0.1",
"description": "", "description": "",

4
server.js

@ -16,9 +16,9 @@ require('dotenv').config()
const app = express(); const app = express();
app.use(cors()); app.use(cors());
const port = process.env.PORT || 3001; const port = process.env.PORT || 3002;
// file name also referenced in flyway.conf and potentially in .env files or in environment variables // file name also referenced in flyway.conf and potentially in .env files or in environment variables
const dbFile = process.env.SQLITE_FILE || './image-db.sqlite'; const dbFile = process.env.SQLITE_FILE || './image.sqlite';
const bucketName = process.env.S3_BUCKET_NAME || 'gifts-image-test'; const bucketName = process.env.S3_BUCKET_NAME || 'gifts-image-test';
const imageServer = process.env.DOWNLOAD_IMAGE_SERVER || 'test-image.timesafari.app'; const imageServer = process.env.DOWNLOAD_IMAGE_SERVER || 'test-image.timesafari.app';

Loading…
Cancel
Save