-
Replace the content of
docker-compose.yaml
with below. What it does is to correct the tool path and add option-C
to trust self-signed certs. This is a MUST_FIX (Please notify prof or TA).version: '3.8' services: node: build: context: ./ dockerfile: Dockerfile image: cosc304-node container_name: cosc304-node volumes: - ./:/app/ - /app/node_modules networks: network304: aliases: - cosc304_node ports: - 80:3000 # This defines port-forwarding configs cosc304-mysql: image: mysql:8.0 container_name: cosc304-mysql restart: always environment: MYSQL_DATABASE: 'testuser' MYSQL_USER: 'testuser' MYSQL_PASSWORD: '304testpw' MYSQL_ROOT_PASSWORD: '304rootpw' ports: - '3306:3306' # This defines port-forwarding configs expose: - '3306' volumes: - mysql-db:/var/lib/mysql - ./ddl:/docker-entrypoint-initdb.d networks: network304: aliases: - cosc304_mysql cosc304-sqlserver: image: mcr.microsoft.com/mssql/server:2019-latest container_name: cosc304-sqlserver restart: always environment: ACCEPT_EULA: 'Y' SA_PASSWORD: '304#sa#pw' ports: - '1433:1433' # This defines port-forwarding configs expose: - '1433' volumes: - cosc304-db:/var/lib/mssql - ./ddl:/scripts networks: network304: aliases: - cosc304_sqlserver command: - /bin/bash - -c - | /opt/mssql/bin/sqlservr & pid=$$! echo "Waiting for MS SQL to be available" /opt/mssql-tools18/bin/sqlcmd -C -l 30 -S localhost -h-1 -V1 -U sa -P $$SA_PASSWORD -Q "SET NOCOUNT ON SELECT \"YAY WE ARE UP\" , @@servername" is_up=$$? while [ $$is_up -ne 0 ] ; do echo -e $$(date) /opt/mssql-tools18/bin/sqlcmd -C -l 30 -S localhost -h-1 -V1 -U sa -P $$SA_PASSWORD -Q "SET NOCOUNT ON SELECT \"YAY WE ARE UP\" , @@servername" is_up=$$? sleep 5 done for foo in /scripts/SQLServer*.ddl do /opt/mssql-tools18/bin/sqlcmd -C -U sa -P $$SA_PASSWORD -l 30 -e -i $$foo done trap "kill -15 $$pid" SIGTERM wait $$pid exit 0 volumes: cosc304-db: mysql-db: networks: network304:
-
To run
node <file>.js
, in the source file, change the server field fromcosc304_sqlserver
tolocalhost
(using port-forwarding as defined in thedocker-compose.yaml
- seeports
spec in each service). For example,dbConfig = { server: 'localhost', // Change here BUT revert when running as a container or submit to Canvas database: 'workson', authentication: { type: 'default', options: { userName: 'sa', password: '304#sa#pw' } }, options: { encrypt: false, enableArithAbort:false, database: 'workson' } }
NOTE: DO NOT INCLUDE THIS CHANGE (point 2) WHEN RUNNING CONTAINERS OR SUBMITTING ASSIGNMENT. Only for local runs with
node <file>.js
.
Last active
November 10, 2024 11:58
-
-
Save tthvo/8935cced2209bc9343c56cb53da3a230 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment