Skip to content

Commit

Permalink
fix docker build and tests, without breaking ci tests, hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
erosson committed May 27, 2024
1 parent b383469 commit bb1ae5b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ RUN yarn

# `.dockerignore` is important to cache this copy properly
COPY . /app/
# RUN . /usr/local/rvm/environments/default && yarn test
# docker seems upset if bower_components is a symlink, for some reason, so copy the whole thing. Works fine in the devcontainer and in CI. Ugh.
# openssl_conf: https://github.com/bazelbuild/rules_closure/issues/351#issuecomment-854628326 . Ugh.
RUN . /usr/local/rvm/environments/default &&\
(cd swarmsim-coffee && rm bower_components && cp -rp node_modules/@bower_components bower_components) &&\
OPENSSL_CONF=/dev/null yarn build
RUN (cd swarmsim-coffee && rm bower_components && cp -rp node_modules/@bower_components bower_components)
# openssl_conf: this fixes tests and build. https://github.com/bazelbuild/rules_closure/issues/351#issuecomment-854628326 . Ugh.
RUN . /usr/local/rvm/environments/default && OPENSSL_CONF=/dev/null yarn test
# `yarn build` includes an application-level ssl redirect. docker doesn't want that!
RUN . /usr/local/rvm/environments/default && OPENSSL_CONF=/dev/null yarn build:docker

# Run the static site we just built. No Caddyfile or other config, just static files.
# "The default config file simply serves files from /usr/share/caddy" - https://hub.docker.com/_/caddy
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"install:link": "(cd tables && yarn link) && (cd swarmsim-ts && yarn link && yarn link @swarmsim/tables) && (cd swarmsim-coffee && yarn link @swarmsim/tables && yarn link @swarmsim/ts)",
"install": "yarn run install:link && (cd tables && yarn install) && (cd swarmsim-ts && yarn install) && (cd swarmsim-coffee && yarn install)",
"start": "(cd tables && yarn build) && (cd swarmsim-ts && yarn build) && concurrently -k 'cd swarmsim-coffee && yarn start' 'cd swarmsim-ts && yarn watch'",
"build": "(cd tables && yarn build) && (cd swarmsim-ts && yarn build) && (cd swarmsim-coffee && yarn _build && cp -rp dist ..)",
"build": "(cd tables && yarn build) && (cd swarmsim-ts && yarn build) && (cd swarmsim-coffee && yarn build && cp -rp dist ..)",
"build:docker": "(cd tables && yarn build) && (cd swarmsim-ts && yarn build) && (cd swarmsim-coffee && yarn build:docker && cp -rp dist ..)",
"start:dist": "serve dist",
"test": "(cd tables && yarn test) && (cd swarmsim-ts && yarn test) && (cd swarmsim-coffee && yarn test)"
"test": "(cd tables && yarn build && yarn test) && (cd swarmsim-ts && yarn build && yarn test) && (cd swarmsim-coffee && yarn test)"
},
"devDependencies": {
"concurrently": "^7.6.0",
Expand Down
33 changes: 32 additions & 1 deletion swarmsim-coffee/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,37 @@ module.exports = function (grunt) {
}
}
},
docker: {
constants: {
env: {
name: 'docker',
isDebugEnabled: false,
isDebugLogged: false,
// httpsAllowInsecure is the only difference from 'prod' - the rest of this should be identical.
// these days, the web server handles all redirects, not the app
httpsAllowInsecure: true,
//gaTrackingID: 'UA-53523462-2'
showSkipped: false,
spreadsheetKey: 'v0.2',
saveId: 'v0.2',
dropboxAppKey: dropboxAppKey('prod'),
isDropboxEnabled: true,
saveServerUrl: 'https://api.swarmsim.com',
isKongregateSyncEnabled: true,
autopushIntervalMs: 1000 * 60 * 15,
googleApiKey: 'AIzaSyCS8nqXFvhdr0AR-ox-9n_wKP2std_fHHs',
// https://developer.playfab.com/en-us/7487/dashboard
playfabTitleId: '7487',
isAppcacheEnabled: false,
sentryDSN: 'https://[email protected]/39331',
sentrySampleRate: 0.001,
isServerBackendEnabled: false,
isServerFrontendEnabled: false,
isPaypalSandbox: false,
gaTrackingID: 'UA-53523462-1'
}
}
},
};
ngconstant.preprod = JSON.parse(JSON.stringify(ngconstant.prod));
ngconstant.preprod.constants.env.saveServerUrl = 'https://api-preprod.swarmsim.com';
Expand Down Expand Up @@ -857,7 +888,7 @@ module.exports = function (grunt) {

grunt.registerTask('build', function(envname) {
envname = envname || 'prod';
if (envname !== 'prod' && envname !== 'preprod') {
if (envname !== 'prod' && envname !== 'preprod' && envname !== 'docker') {
throw new Error('invalid build envname: '+envname);
}
console.log('building envname '+envname);
Expand Down
5 changes: 2 additions & 3 deletions swarmsim-coffee/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@
"tf:apply": "set -a && . ~/.cloudflare.env && set +a && terraform apply -auto-approve",
"start": "grunt serve",
"start:dist": "cd dist && serve",
"// build": "openssl_conf export: https://github.com/bazelbuild/rules_closure/issues/351#issuecomment-854628326",
"build": "yarn test && yarn _build",
"_build": "grunt build && yarn _build:ts",
"build": "grunt build && yarn _build:ts",
"build:docker": "grunt build:docker && yarn _build:ts",
"_build:ts": "rm -rf ./dist/swarmsim-ts && cp -rp ./node_modules/@swarmsim/ts/dist/coffee-embed ./dist/swarmsim-ts",
"preversion": "yarn test",
"_pretest": "grunt pretest",
Expand Down

0 comments on commit bb1ae5b

Please sign in to comment.